Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: JosJuice on October 05, 2010, 12:59:45 pm

Title: Homescreen or graphscreen?
Post by: JosJuice on October 05, 2010, 12:59:45 pm
Yeah... It wasn't long ago since I started coding TI-BASIC and now I've gotten to the point where I want to display graphics that aren't just ASCII characters. So I'm wondering: Should I use the homescreen or the graphscreen? As I understand it, graphscreen allows stuff like drawing lines, but homescreen allows Disp. Are there any other important differences, and which screen would be the best to use when drawing sprites?

And also, how do I swap between the two screens from a program? Do I simply use a function for drawing to the screen I want to swap to? I didn't exactly see any function for swapping when I looked in the manual.
Title: Re: Homescreen or graphscreen?
Post by: Raylin on October 05, 2010, 01:08:30 pm
Graphscreen. You cannot make non-ASCII characters any other way.

Also, in regards to the swapping thing, certain commands drop you back to the homescreen. Try fiddling with some of those.
Title: Re: Homescreen or graphscreen?
Post by: JosJuice on October 05, 2010, 01:13:17 pm
Graphscreen. You cannot make non-ASCII characters any other way.
So the function that draws a single pixel only works on the graphscreen?
Title: Re: Homescreen or graphscreen?
Post by: Raylin on October 05, 2010, 01:20:57 pm
Yes. It also switches to the graphscreen on execution if I recall correctly.
Title: Re: Homescreen or graphscreen?
Post by: JosJuice on October 05, 2010, 01:22:54 pm
Is that function fast or should I avoid overusing it?
Title: Re: Homescreen or graphscreen?
Post by: Builderboy on October 05, 2010, 01:49:36 pm
None of the Basic commands are what i would call fast, but the pixel routine is (i believe) the fastest graphical command. NOTE however, that there is a very important difference between Pixel plotting and Point plotting.  Pixel plotting works off of the screen coordinates, so 0,0 is always in the top left hand corner.  Point plotting works off of the graph screen coordinates, so they depend on your window settings.

Also note that while a single pixel plot is faster than a single line command, it is definetaly faster to use the line() command to draw a line than use a bunch of pixel() commands to draw it.  And actually you kind of can switch between the screens, Disp without any arguments brings you to the homescreen, and dispGraph brings you to the graph screen.  Using graph functions will also bring you to the graph screen (except ClrDraw) and using homescreen functions will bring you to the homescreen. 

Its also worthy to note that no command that works on one screen also works on the other screen.
Title: Re: Homescreen or graphscreen?
Post by: JosJuice on October 05, 2010, 01:53:22 pm
Okay. Thanks to both of you. I'll start coding something soon (or maybe in a week if I'm lazy :P)
Title: Re: Homescreen or graphscreen?
Post by: DJ Omnimaga on October 05, 2010, 02:39:27 pm
Another way to speed things up is to use two (or three?) ASCII character combined together to draw tilemaps.

ClrDraw
For(A,0,56,7
Text(A,0,"OOOOOOOOOOOOOOO
End
Storepic 0
For(A,0,56,7
Text(A,1,"HHHHHHHHHHHHHHH
End
Recallpic 0
Storepic 0

It gives some pretty amazing results sometimes, while still running pretty fast. :)

Example of game using such technique:
(http://www.omnimaga.org/images/screenshots/DemoScreeeenie2.gif)
Title: Re: Homescreen or graphscreen?
Post by: ztrumpet on October 05, 2010, 07:32:54 pm
Here's a summery of Graphics: http://tibasicdev.wikidot.com/graphics
I hope you are able to do well with this first transition to the graphscreen. :)  Good luck! ;D
Title: Re: Homescreen or graphscreen?
Post by: Deep Toaster on October 05, 2010, 07:34:46 pm
Graphscreen. You cannot make non-ASCII characters any other way.

Plus, you can combine the two, and even ASCII chars aren't that slow on the graph screen if you draw them with Text(-1.
Title: Re: Homescreen or graphscreen?
Post by: AngelFish on October 05, 2010, 08:26:28 pm
Are there any other important differences, and which screen would be the best to use when drawing sprites?

Sprites are rather difficult to do [quickly] in BASIC with non-ASCII characters, especially if you have a constantly changing background.
Title: Re: Homescreen or graphscreen?
Post by: Deep Toaster on October 05, 2010, 08:35:16 pm
Pixel-based sprites are actually faster than text sprites, but bigger.
Title: Re: Homescreen or graphscreen?
Post by: DJ Omnimaga on October 06, 2010, 01:43:54 am
I don't think so. Good luck, Deep Thought, at rendering a 12x8 tilemap in 3 seconds in pure-BASIC. With dual-layer text as shown in the screenshot above, it takes about 2-3 seconds and with single-layer ascii it takes half a second.
Title: Re: Homescreen or graphscreen?
Post by: JosJuice on October 06, 2010, 01:46:57 am
Pixel-based sprites are actually faster than text sprites, but bigger.
Bigger in which way? Does the program get larger?
I don't think so. Good luck, Deep Thought, at rendering a 12x8 tilemap in 3 seconds in pure-BASIC. With dual-layer text as shown in the screenshot above, it takes about 2-3 seconds and with single-layer ascii it takes half a second.
I guess I'll have to try to avoid drawing too much stuff, then. (Or maybe I should switch to Axe :D)
Title: Re: Homescreen or graphscreen?
Post by: DJ Omnimaga on October 06, 2010, 01:54:34 am
There is also xLIB or Doors CS that supports sprites. But yeah if your sprites are just made of two lines for example it should not be too slow. But they still becomes much larger in file size than text ones. In Axe they aren't too large, though (8 bytes for a 8x8 sprite)
Title: Re: Homescreen or graphscreen?
Post by: Deep Toaster on October 06, 2010, 11:38:50 am
Quote from: DJ Omnimaga
I don't think so. Good luck, Deep Thought, at rendering a 12x8 tilemap in 3 seconds in pure-BASIC. With dual-layer text as shown in the screenshot above, it takes about 2-3 seconds and with single-layer ascii it takes half a second.

I meant as compared to small-text 5x5 sprites. I need to start using 5x7...
Title: Re: Homescreen or graphscreen?
Post by: AngelFish on October 06, 2010, 12:40:17 pm
Pixel-based sprites are actually faster than text sprites, but bigger.
Bigger in which way? Does the program get larger?

Yes, the source code almost always expands because you have to use multiple pixel or Line drawing commands.

It's best to make pixel based sprites as small and simple to draw as possible. For example, when I did CAD (see picture below), the only way I could draw the cursor sprite in real time was to make it those four pixels you can see. Of course, the projection algorithms massacred any optimizations I made to the code, but that's beside the point.

(http://farm2.static.flickr.com/1379/4733757679_2b3192d4fd.jpg)
Title: Re: Homescreen or graphscreen?
Post by: DJ Omnimaga on October 06, 2010, 02:05:09 pm
Quote from: DJ Omnimaga
I don't think so. Good luck, Deep Thought, at rendering a 12x8 tilemap in 3 seconds in pure-BASIC. With dual-layer text as shown in the screenshot above, it takes about 2-3 seconds and with single-layer ascii it takes half a second.

I meant as compared to small-text 5x5 sprites. I need to start using 5x7...
Ah right, that would indeed be slower than actual sprites in some cases. That's unless the text sprites are complex, though, cuz in that case the same pixel based sprite may end up slower.

Pixel-based sprites are actually faster than text sprites, but bigger.
Bigger in which way? Does the program get larger?

Yes, the source code almost always expands because you have to use multiple pixel or Line drawing commands.

It's best to make pixel based sprites as small and simple to draw as possible. For example, when I did CAD (see picture below), the only way I could draw the cursor sprite in real time was to make it those four pixels you can see. Of course, the projection algorithms massacred any optimizations I made to the code, but that's beside the point.

(http://farm2.static.flickr.com/1379/4733757679_2b3192d4fd.jpg)
Wow I swear I saw this program somewhere. I think it was on Cemetech, TI-BASIC Developper or Ticalc.org
Title: Re: Homescreen or graphscreen?
Post by: AngelFish on October 06, 2010, 02:17:29 pm
It would probably be on TI-Dev unless someone took the liberty of posting it on another forum. That's where I posted the screenshots of the program, although I never got a chance to post the completed program (frikkin' mathprint).
Title: Re: Homescreen or graphscreen?
Post by: DJ Omnimaga on October 06, 2010, 02:18:15 pm
Ah ok I see. It might be TIBD then. What happeend with MathPrint? Did you got hit by a memory clear?
Title: Re: Homescreen or graphscreen?
Post by: AngelFish on October 06, 2010, 02:20:10 pm
Yep. I was innocently using the exponential key when I hit the clear button halfway through the expression. That particular sequence causes an error in the program and crashes the calc. CAD was in RAM at the time...
Title: Re: Homescreen or graphscreen?
Post by: DJ Omnimaga on October 06, 2010, 02:23:30 pm
X.x

This is when we want to switch to Casio rant about TI the most X.x

Backups are always nice, but when you use pure-BASIC, you don't expect RAM clears to occur.
Title: Re: Homescreen or graphscreen?
Post by: ztrumpet on October 06, 2010, 05:23:32 pm
* ZTrumpet shakes fist at TI! D=

I've been able to achieve some pretty stunning graphics in pure basic; Click the Exodus and Elmgon banners in my sig to see some of what I've accomplished with zero Asm help. ;D
Title: Re: Homescreen or graphscreen?
Post by: Deep Toaster on October 06, 2010, 08:02:32 pm
Yep. I was innocently using the exponential key when I hit the clear button halfway through the expression. That particular sequence causes an error in the program and crashes the calc. CAD was in RAM at the time...

I KNEW IT! I got that glitch once too, but I didn't remember how.

Btw, that prgm looks really nice.
Title: Re: Homescreen or graphscreen?
Post by: DJ Omnimaga on October 07, 2010, 02:16:11 am
Yep. I was innocently using the exponential key when I hit the clear button halfway through the expression. That particular sequence causes an error in the program and crashes the calc. CAD was in RAM at the time...
Could you create a screenshot of how you actually recreate this error? I cannot reproduce it with the steps explained in your post. ???
Title: Re: Homescreen or graphscreen?
Post by: Builderboy on October 07, 2010, 02:19:28 am
I think he meant he was doing an expression on the homescreen that included fractions and stuff maybe?
Title: Re: Homescreen or graphscreen?
Post by: DJ Omnimaga on October 07, 2010, 02:48:08 am
Mhmm... weird, I tried messing with those and got no issues. It would be nice if a screenshot was posted showing exactly how to recreate the error.
Title: Re: Homescreen or graphscreen?
Post by: Builderboy on October 07, 2010, 02:48:31 am
Yeah sounds obscure
Title: Re: Homescreen or graphscreen?
Post by: Deep Toaster on October 07, 2010, 07:13:54 pm
Yeah sounds obscure

It is. I've only had it happen once. I had a really complicated expression on the screen, full of exponents, and I did something that caused a RAM clear. I don't remember what, though :P But that made me decide immediately that I would never, ever upgrade anyone to 2.53MP.