Join us on Discord!
You can help CodeWalrus stay online by donating here.

CE Textlib/Basic Drawing

Started by Dudeman313, March 11, 2016, 11:34:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dudeman313

I was thinking about porting some of my favorite basic games, to get past only Text games.
I thought of Shift, even though it's made in xLib, maybe I could draw sprites in pure basic?

Anyway, I found you can draw sprites with the Px-On command by looking thru someone's tutorial on ticalc.org, but it takes forever,
especially on my CE, and drawing sprites pixel by pixel on a 320x240 screen is pretty much torture.
@DJ Omnimaga said you can draw with CE Textlib, and I'd like to know how.
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


KingInfinity

Protip: Wait for xLIBCE :)
Real answer: You probably can. but xLIBCE and Doors CE 9 will empower and enable you to create programs on a larger and better scale.

Dudeman313

So, just forget it and wait for XX months/years?  :-\
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Adriweb

Well, you have C programming on the CE, if you want :)
And there are libs already available, including for graphics (example here)

(Also, self-promotion: and even an online builder (still in beta) compatible with the latest toolchain, if you don't feel like setting up the toolchain locally)
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Dudeman313

I was just trying to learn to do some stuff in Basic, which I somewhat understand. C looks terribly foreign to me, much like Russian.
I guess I could try it, though, if the tutorial was finished...  <_<

Well, then there's no point in this topic if I'm not getting any help out of it...   :-|
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Dream of Omnimaga

#5
This topic is about CE Textlib and pure BASIC drawing commands support, not about xLIBC nor C. Those should be kept separate if Dudeman313 ever needs help with them.

Anyway I didn't have time to help because I spent the last two hours on the phone and the previous ones at work, but I suggest against drawing sprites pixel by pixel, since that's too slow. There are plenty of tricks to draw BASIC sprites at a somewhat decent speed (if you don't need to move them around, that is), which involves tricks such as text sprites, using lists and the Line command and stuff, but it would take a while to explain all.

Have you checked TI-Basic Developer wiki for info about the Line(), Pt-On, Pt-Off and Text() commands? I think they updated the wiki to include extra color stuff, but I'M unsure.

As for CE Textlib, the readme explains each command, but if you need help with a specific one then let me know. I was kinda joking about the CE Textlib sprites, though. While it's technically possible to draw a 26x10 sprite using CE Textlib, it's not practical, because just a 8x8 sprite alone almost fills the entire screen height and the resulting code is very large. It's done by using the rectangle commands, but those rectangle commands can be handy to erase large parts of the screen. And of course you can also draw colored text.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Adriweb

Quote from: DJ Omnimaga on March 12, 2016, 02:23:40 AMThis topic is about CE Textlib and pure BASIC drawing commands support, not about xLIBC nor C. Those should be kept separate if Dudeman313 ever needs help with them.
I was rather replying with an alternative solution since he seemed desperate with his "So, just forget it and wait for XX months/years? :/" message.
But sure, if the discussion ends up on more C stuff, he might as well make another proper topic about that.
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Dream of Omnimaga

#7
Ah ok. CodeWalrus tends to be open to learning of any language so I thought that if he was willing to learn TI-BASIC, that the topic should be about that, but of course I can understand that waiting XX months/years for xLIBC release (worst case scenarios, of course) isn't very productive compared to sticking to the current tools or trying C. But yeah in TI-BASIC and with CE Textlib, you can still do some decent stuff. It takes skills no matter the language used, though, so he needs to learn the basic concepts first prior getting into elaborate tricks.

However, an example of what I meant for CE Textlib sprites is this:

{33,1,1,10,26,12,33,1,3,1,4,22,33,1,9,1,4,22,33,2,3,2,10,20,33,2,1,2,2,18,33,3,3,1,2,18,33,2,7,2,2,18,33,3,9,1,2,18,33,2,13,2,2,18,33,4,1,4,16,22,33,5,3,2,2,20,33,5,7,2,2,20,33,8,1,1,2,22,33,8,5,1,4,22,33,8,11,1,4,22
Asm(prgmTEXTLIB


Here I use 15 rectangles to erase the entire screen, then draw the :walrii: from @JWinslow23 's Atari 2600 port of Wal-Rush every frame. (I got the colors wrong, though). I get 4 FPS, which isn't that great, but it still shows what can be achieved.
I made it flicker on purpose to show the speed. Also, the pixels are doubled in there, so technically it's a 16x8 sprite:




Here is a version where it isn't erased every frame, but changes color:
1→A
{33,0,1,11,26,18
Asm(prgmTEXTLIB
{11,23,18,23→L₁
While 1
L₁(A
{33,1,3,1,4,Ans,33,1,9,1,4,Ans,33,2,3,2,10,20,33,2,1,2,2,17,33,3,3,1,2,17,33,2,7,2,2,17,33,3,9,1,2,17,33,2,13,2,2,17,33,4,1,4,16,Ans,33,5,3,2,2,20,33,5,7,2,2,20,33,8,1,1,2,Ans,33,8,5,1,4,Ans,33,8,11,1,4,Ans
Asm(prgmTEXTLIB
A+1→A
If A>4:1→A
End





You can also use the pure BASIC Pt-On command to draw small dots that are larger than with Pxl-On to form small sprites. But Pt-On uses graphing coordinates, not screen, so you need to set Xmin, Xmax and stuff beforehand.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Dudeman313

#8
Interesting. I'll look into this when I have a bit more time.

EDIT
So, Textlib does everything on the Home Screen? Found that out w/ some experimentation.
And if I wanted to port something like Shift, I could use rectangles for most things?
Would it be really slow if I made the rectangles pixel sized? I found that I can't.

How do I determine where the rectangle will start?
How do I set the color while drawing? Apparently, 20 is white, 18 is blue, but 5 is black?
To make the background white, will I have to cover the screen w/ a white rectangle and draw over it?
How do I move the rectangles, specifically with the keys(jumping & such)?




  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Dream of Omnimaga

I don't know if CE Textlib rectangles are drawn on the home screen. I would need to do some testings.


Rectangles coordinates are the same as the Output() command. Y goes from 1 to 10 and X from 1 to 26. But for some reasons, we can also draw them outside those boundaries as long as you don't use negative coordinates. Whether this can cause stability issues have yet to be seen. Colors are the same as in TI-BASIC and rectangle size is actually the size of an Output character, so no, you can't draw them of any size.

10 Blue
11 Red
12 Black
13 Pink
14 Green
15 Orange
16 Brown
17 Yellow
18 Dark blue
19 Light blue
20 White
21 light gray
22 light-medium gray
23 medium gray
24 dark gray
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Dudeman313

Thanks! ;D
I'm going to see if I can add CE Textlib graphics to a Timber Dodge game
on Cemetech, but I should probably ask the author first.

Also, can you color Output( functions individually?
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Dream of Omnimaga

Ask the author first, of course. And yeah you can color Output commands individually, but that requires using several Asm() commands which is very slow. Ideally, you should do all the static background drawing before the game starts, then during gameplay you should never change the Output colors at all, to keep speed to a maximum. You could maybe switch colors twice per loop but you'll already notice a slowdown.

It's because when you use the Asm() command, the calculator searches the VAT (variable allocation table) to find prgmTEXTLIB in the calculator RAM and archive, which takes a long while.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Dudeman313

I have asked him, and when he replies I may/may not start the project. :)

Well, I am using background/foreground settings, but I need to color a few things differently than everything else.
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Dream of Omnimaga

On a side note, do you know that you can also use colored text on the graph screen but without any BASIC library? The only issue is that you can't choose the background. White, yello and light gray text has a mid gray background, while everything else has a white background. But I thought I would let you know in case this might suit your needs.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Dudeman313

#14
Well, both my game and CalcGuy123's TimberDodge are made on the home screen, and I'm somewhat lazy(:trollface:) and don't want to reprogram them both just to color them on the graph screen. And if I can't choose the background then there's no point, because I want to make TimberDodge's background blue and green, like your Wal-Rush.

So, about coloring Output( functions?
I'd like to know how to color ones individually and if it's possible to use one command to color several(but not all).

Also, 655 posts already! Wow! O.O
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Powered by EzPortal