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

How do I load an image into a GROB on the HP Prime?

Started by Strontium, September 13, 2015, 08:01:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Strontium

How do I load an image into a GROB on the HP Prime? I want to load in a sprite sheet I got, and use SUBGROB_P to draw separate sprites.if I used any wrong terminology here please tell me
  • Calculators owned: TI Nspire CX, HP Prime
  • Consoles, mobile devices and vintage computers owned: NES

Dream of Omnimaga

I don't remember seeing a SUBGROB command, unless it was added in recent OS updates, so I can't help on using it. However, I know the DIMGROB_P and BLIT_P commands.

Do you have your sprite data loaded in your program code by the way? If not, then use http://www.hpcalc.org/details.php?id=7472 to generate it. ICON is smaller, but slower and deprecated, while GROB format is faster but considerably larger.


Now onto sprite displaying. Basically, you have 10 graph buffers called GROB. 0 is the LCD content and can only be 320x240, while 1 through 9 are extra buffers that can be any size. 1 through 9 are dimensioned by using DIMGROB_P(width,height,defaultcolor) (for example, DIMGROB(320,240,#000000) ). The BLIT_P command is used to copy a section of a GROB into a section of another. Here is an example:

EXPORT SPRITE()
BEGIN
DIMGROB_P(G1,16,16,#000000); //creates 16x16 graph buffer into GROB 1
BLIT_P(G1,0,0,16,16,G0,304,0,320,16); //copies the LCD content located at (304,0,320,16) coordinates into the 16x16 area available in GROB 1
BLIT_P(G0,0,0,320,240,G1,0,0,16,16); //copies GROB 1 content located at (0,0,16,16) into the LCD, scaled up to fit the entire scren
WAIT(); //crash the calculator or wait until a key is pressed, depending of the OS being used
END;




Scaling should be kept to a minimum, though, to avoid lag. Or if you want your game to be 80x60 with 8x8 sprites, for example, just draw them into a 80x60 GROB then once done you just display that GROB 4x larger on the LCD.
  • 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

Strontium

Thanks! Could you post an example output of dimgrobhelper so I can see how to use it? I cant test it right now because i have no access to my computer.
  • Calculators owned: TI Nspire CX, HP Prime
  • Consoles, mobile devices and vintage computers owned: NES

Dream of Omnimaga

For the first frame of :walrii: with a pink background, here is the GROB format:

DIMGROB_P(G1, 24, 24, {#7C1F7C1F7C1F7C1F:64h ,#7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,#77DE7BDE77DE0000:64h ,#7C1F0000:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,
   #7C1F7C1F7C1F:64h ,#7FFF7FFF7BDE77DE:64h ,#77DE77DE000077BD:64h ,#7C1F7C1F7C1F0000:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,#77BD00007C1F7C1F:64h ,#739C0000000077BE:64h ,#7FFF7FFF739C0000:64h ,#7C1F7C1F00007BDE:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,
   #6F7C00007C1F7C1F:64h ,#1A5B1A5D0000:64h ,#7FFF7BDE00000000:64h ,#77DE7FFF:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F:64h ,#15E015F1A5D:64h ,#7BDE00001A5D161A:64h ,#4E7300007BDE7FFF:64h ,#7C1F7C1F7C1F0000:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F:64h ,
   #15E015F163C:64h ,#1A5D015F015E:64h ,#56B5000077BD7BDE:64h ,#7C1F7C1F000056B5:64h ,#7C1F7C1F7C1F7C1F:64h ,#39EF4E7300007C1F:64h ,#13B013C0000:64h ,#1A5D015F013C:64h ,#463142100000739C:64h ,#7C1F7C1F00005AD6:64h ,#7C1F7C1F7C1F7C1F:64h ,#42103DEF00007C1F:64h ,
   #35AF0000000039CF:64h ,#6B7B0000013A0000:64h ,#463142103DEF0000:64h ,#7C1F000052B54631:64h ,#7C1F7C1F7C1F7C1F:64h ,#35AD00000000:64h ,#3DEF3DEF3DEF39CE:64h ,#39CF:64h ,#4631463142103DEF:64h ,#7C1F000056B54631:64h ,#7C1F7C1F7C1F7C1F:64h ,#67390000:64h ,#39CE3DEF0000:64h ,
   #3DEF3DEF3DEF3DEF:64h ,#4631463146314210:64h ,#7C1F000056B54631:64h ,#7C1F7C1F7C1F7C1F:64h ,#6F7B77BD0000:64h ,#6739:64h ,#4631463146313DEF:64h ,#4631463146314631:64h ,#52B546314631:64h ,#7C1F7C1F7C1F7C1F:64h ,#7BDE7BDE0000:64h ,#6B5A7FFF77BD:64h ,#4631463146313DEF:64h ,
   #4631463146314631:64h ,#56B546314631:64h ,#7C1F7C1F7C1F7C1F:64h ,#7BDE7BDE0000:64h ,#7BDE7FFF7BDE:64h ,#4631463146313DEF:64h ,#4631463146314631:64h ,#3DEF46314631:64h ,#7C1F7C1F7C1F7C1F:64h ,#6F7B77BD0000:64h ,#7BDE7FFF7BDE:64h ,#4631463146313DEF:64h ,#4631463146314631:64h ,
   #3DEF46314631:64h ,#7C1F7C1F7C1F7C1F:64h ,#6B5A0000:64h ,#739C7FFF6F7B:64h ,#4210421042103DEF:64h ,#4631463146314631:64h ,#421046314631:64h ,#7C1F7C1F7C1F7C1F:64h ,#67390000:64h ,#3DEF00006F7B0000:64h ,#421000003DEF4210:64h ,#4631421042104210:64h ,#56B55AD646314631:64h ,
   #7C1F7C1F7C1F0000:64h ,#7C1F000067390000:64h ,#3DEF000067390000:64h ,#46313DEF00004210:64h ,#42103DEF00004631:64h ,#5AD6463146314631:64h ,#7C1F7C1F00000000:64h ,#63180000:64h ,#3DEF000067390000:64h ,#4631421042104210:64h ,#3DEF000056B55AD6:64h ,#4631421042104210:64h ,
   #7C1F000000005294:64h ,#4A52000000007C1F:64h ,#3DEF000063180000:64h ,#4631421042104210:64h ,#56B55EF74631:64h ,#421000003DEF3DEF:64h ,#7C1F7C1F000056B5:64h ,#56B5000000007C1F:64h ,#39CE39CE00004210:64h ,#42103DEF000039CE:64h ,#5AD646314631:64h ,#3DEF00003DEF3DEF:64h ,
   #7C1F000052B54631:64h ,#46314E7300007C1F:64h ,#35CE3DEF:64h ,#39CE0000318D0000:64h ,#5294463146313DEF:64h ,#35CE35AD0000:64h ,#39CE3DEF3DEF:64h ,#3DEF39CE00007C1F:64h ,#7C1F7C1F00000000:64h ,#7C1F:64h ,#4E73421039EF0000:64h ,#7C1F000000000000:64h ,#7C1F000000000000:64h ,
   #7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F7C1F7C1F7C1F:64h ,#7C1F:64h ,#7C1F7C1F7C1F0000:64h ,#7C1F7C1F7C1F7C1F:64h });


And here is the icon format:

ICON name 89504E470D0A1A0A0000000D4948445200000018000000180803000000D7A9CDCA00000078504C5445FF00FF030303EEF0F1F0F0F0F8F8F8E8E8E8EDEFF1E3E3E3DCDEE13193E83191DF0357FF0453F02986D79B9B9B2E8FE3A8A8A876787A044FE3044CDB808080898989B1B1B178787874767A6A6F7A0449D2D6D9DAA7A8A96D6D6D717171CACACADFDFDFD7D7D7C3C3C5A2A2A2939393BEBEBE6E70716667682E7C3B5B0000002874524E5300000000000000000000000000000000000000000000000000000000000000000000000000000000F694B057000000F14944415478016DD20D7782201886616FC5395773D640F649B68FF6FFFFE11E40D3B638C753BC573C2F60451A40716D505625C57F54DD989AB2FC23D437D0D018535D0AB7B477EAA265E5451CB49B2DF7ADA4A25B093C08B61B494DDF9F856EC7FE91BDA0C1BA61016F9FE099175EF5D5B9B749E09DE0BD17A6BA9BB338C44A4096EA0BD46336378F298BAAA236C715F40BC4032CE039475D87238CA6D18E6CEAED9C65D9D5A8BAC7661B7213417CBC8D61F92443BA4A3EB4E29093F4DBF4F999852F616EF12D51E494456F0921A4982182CF67A473FEA4B81F5D9953CAFB4918249A4F91B0B35DFCC3301756EFEC3CF905F83F13975044D8F70000000049454E44AE426082;

If you decide to use ICON format, you have to place it at the very end of the program, below the final END, then to use it, you have to use, for example, BLIT_P(G0,0,0,24,24,"name", 0,0,24,24,#ff00ff) instead of BLIT_P(G0,0,0,24,24,G1,0,0,24,24,#ff00ff). #ff00ff is optional there, but it makes the pink background transparent.

And backup often, very often. Emulator content ends up in the C:\Users\DJOmnimaga\AppData\Roaming\HP_Prime folders (or HP_Prime 1, etc), but you can also back up in other ways and stuff. Just do it often because after transfering many files the calc seems to become unstable. And do some ON+Symb from time to time when not inside the program editor.
  • 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

Strontium

#4
For the thing I am doing, I can probably get away with using ICON, since the game I want to make only does logic and drawing every turn (since, well, it's turn based). And ICON takes less space and looks a bit easier to use. Thanks!
  • Calculators owned: TI Nspire CX, HP Prime
  • Consoles, mobile devices and vintage computers owned: NES

Dream of Omnimaga

ICON should be fine for the time being. Tim Wessman discourages using it and encourages using applications instead of programs, but I think the app system is not mature enough to be used yet and GROB is extremely large. If you ever need speed, you can just copy your ICON in a temporary GROB at the game start then use that GROB. ANd even then, ICON is generally very fast anyway.
  • 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

Strontium

What exactly is the difference between apps and programs? I've never made an app before, so I have no idea.
  • Calculators owned: TI Nspire CX, HP Prime
  • Consoles, mobile devices and vintage computers owned: NES

Dream of Omnimaga

Apps shows up in the apps menu and the file format is different. The nice thing about them is that they allow the app file to have a logo, but it's a major PITA for users to send and run apps properly, especially newbies. Hence why I still use regular programs. Both use HP PPL langage.
  • 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

Strontium

  • Calculators owned: TI Nspire CX, HP Prime
  • Consoles, mobile devices and vintage computers owned: NES

Dream of Omnimaga

I hope that HP updates apps in the future to be more user-friendly to send, though. But yeah, as you are new I would recommend sticking to apps for now. By the way, remember also to start with small projects since you are new to HP PPL. (they can still have advanced graphics and animations, but ideally avoid making a big space shooter or RPG as first project until you're ready)
  • 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