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

Prime PPL animated graphics question

Started by Peyrol, January 13, 2015, 02:57:41 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Peyrol

First, I am grateful this forum exists.

I am considering purchase of a Prime. One big reason to buy is so I can develop animated graphics programs. I looked at the HP Prime user guide, and it mentions 10 GRaphics OBjects, with G0 apparently always set as the screen display. This is a little confusing to me. I am used to the concept of double buffering, where the screen display can shift from one graphics object to another, so that changes applied to the entire screen will appear all at once as we update from one frame to the next. But I watch the Prime "Programming Tribute Video" and see lots of cool animations, so there must be a way to quickly update each new screen. How is it done? Any clue would be appreciated. TIA

Dream of Omnimaga

#1
Hiya and welcome here. :D Congratulations: You found a calculator that can do it very easily and fast without much external assistance. :D (although beware of some OS bugs).

Basically, the G0 to G9 graphical objects let you do double-buffering like you see fit and with 10 objects total, you could even do tentuple-buffering :D.


As for screen update speed the reason why it's done so fast in the video is because the calculator's built-in language, HP PPL, is that fast. It can surprise people who are used to HP 50g or even TI-BASIC speed (which can still do very decent stuff), but yeah, you can basically make action games on this platform.

How it's done is another story, though, because it would take me a while to explain and I am a bit busy for that :P. There are probably some tutorials and documentation online on how to use DIMGROB_P and BLIT_P commands, as well as that one tool to convert image files to HP Prime PNG format. But basically, DIMGROB_P is the command to setup a graphical object. That object can be any size, so you could easily store several dozens of screens into one (although I usually recommend working with small GROB's such as 336x256 since the calculator can get a bit unstable otherwise), while you could easily just use a tiny GROB to store a few 16x16 icons/sprites.

The BLIT_P command lets you copy a part of a GROB variable (G0 being the screen itself) or part of PNG image data into another GROB of your choice. You can even scale the graphical chunks up or down, although that slows things down.

Here is an example program demonstrating how you can use BLIT_P and DIMGROB_P commands: http://codewalr.us/index.php?topic=124.0 . If you ever figure out how to just shift the screen and only draw the missing rows of tiles to speed things up, then you could write a Mario game. Or you could add some frame skipping to the mix and do Sonic. It's best to start smaller, though :P

Also, as an advice: If your calculator ever freezes or acts erratically, the ON+SYMB key combo is your friend. It will reboot the calc but you should not lose your programs (backup often, though, like with any other platform!) :)
  • 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

Peyrol

Wow that looks super easy. So, whenever you execute a BLIT_P command with G0 as the destination, the screen will refresh, is that right? What sort of frame rate is that on your demo, looks like around 20 fps?
Thank you so much!

Dream of Omnimaga

It will update the screen area that you specified. If you use G1 instead, then it will update the specified area of that GROB. As for frame rate it depends of how complex the program is, but the star animation above is around 15 FPS. It would be much faster if I pre-rendered everything before runtime then scrolled one massive 320x240 GROB around. The calculator screen is about 52 Hz if I remember, so if a program runs much faster than 52 FPS it will start skipping some frames.
  • 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

Peyrol

That's great news. I hope to afford a Prime soon. Thanks so much.

Dream of Omnimaga

Aah I thought you already had the calculator. I hope you get one soon too. In the meantime, you can try it in the emulator that is freely available, although keep in mind it runs much faster than the real calculator (all video screenshots were slowed down to match real hardware speed)
  • 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

Powered by EzPortal