CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: alexgt on May 10, 2016, 11:34:15 am

Title: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 10, 2016, 11:34:15 am
So this is the place to share any tests or tricks you have learned while programming/ using the HP Prime!

So DJ was wondering about if the new firmware made any speed differences with the speed of displaying GROBs, I have updated to the firmware 107701 (if that is the right number xD) and here is the speeds (in milliseconds):

G1 is set to 320x240
G1 no zoom, no alpha blending: 3-12 (consistent mostly on 3 with some spikes)
G1 2x zoom, no alpha blending: 29-41 (we see a significant speed drop here but I didn't specify the exact cords on G1 on what to display, when I did that it went down to 29-35 which isn't that big of a drop though)
G1 no-zoom, 50% alpha blending: 17-26 (it jumped once to 40 but that was only once)
G1 2x zoom, 50% alpha blending: 49-53 (this is super high so don't use this combo unless you are not drawing to the screen frequently)
G1 4x zoom, no alpha blending: 29-37, I don't know why 2x and 4x are so similar but it is probably because it stops drawing pixels after the coords are more than 320,240 or less than 0,0.
G1 4x zoom, 50% alpha blending: 49-56 again with the zoom and alpha the render time is high but like the others it is about the same to 2x zoom for some reason.

There is one bug with BLIT however and that is when you try and use 12 arguments. I saw a post on hp museum that said something about it and @timwessman confermed that it was a problem with the amount of args and it is a known bug. So that means you can't do zoom with alpha blending <_<. but that only means that 2 tests cannot be complete...

I used this program to time them:

EXPORT LineTime()
BEGIN
DIMGROB_P(G1,320,240);
A:=TICKS;
BLIT_P(G0,G1,[other arguments]);
B:=TICKS;
END;
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 10, 2016, 08:07:58 pm
Interesting, but didn't he say that you can simply omit the G0 at the start (since it defaults to G0 for BLIT_P)? IIRC that allowed you to squeeze the extra blending argument in.

Also you totally misspelled Tim Wessman's name there so I fixed it <_<
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 11, 2016, 12:48:40 am
Quote from: DJ Omnimaga on May 10, 2016, 08:07:58 pm
Interesting, but didn't he say that you can simply omit the G0 at the start (since it defaults to G0 for BLIT_P)? IIRC that allowed you to squeeze the extra blending argument in.

Also you totally misspelled Tim Wessman's name there so I fixed it <_<

Oops, about the name and the command xD. Sorry Tim. But yeah, I will edit that tomorrow since I need to do homework.

EDIT: And on a side note is HP selling wireless connectivity kits because I really want one <_<
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 11, 2016, 03:21:28 pm
I don't remember if the wireless kit is available for sale yet, but you need hardware C anyway so if your calculator is too old then it might not be compatible. If the HP Prime was more mainstream then the wireless unit would have ruled, since we could have gotten some multiplayer games.
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 11, 2016, 03:27:34 pm
I think I have hardware version C since I got a new calc off the warranty for since mine had a broken screen :P
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 11, 2016, 03:35:31 pm
Oh right, but again we never know, since on HP website they still sold both hardwares as separate item IDs not so long ago.

By the way, did you have any luch testing the speed of alpha-blended graphics with the method I suggested?
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 11, 2016, 04:31:11 pm
sorry, I haven't done that but I will on the bus today ;)
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 11, 2016, 07:48:16 pm
Ah ok. Let me know when you did it (maybe edit the first post and @mention me in a new post). Or report if it doesn't work (it might also be wise to report the issue on HP Museum if even omiting G0 doesn't work)
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 12, 2016, 12:54:50 am
Sure thing, I am posting the results now

EDIT: @DJ Omnimaga the results are posted ;)
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 12, 2016, 03:21:15 am
Thanks for the tests. I think the speed isn't bad so that could still be handy for stuff that doesn't require speed. :) (and maybe make it easier to do :walrii: Maker
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 12, 2016, 11:47:53 am
Yeah, come to think of it if I made a walrii mob then I would have the colors randomized O.O
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 12, 2016, 07:16:31 pm
That could work. My idea actually was to use alpha blending for the shading of the walrus sprites, such as making a 2nd layer with white and black pixels displaying at 36% opacity and a third layer with 18% opacity or something like that. So I could change the gray in the Walrii sprite to anything without losing the rest. I would also need to allow choosing different types of shading, though (since some walrus sprites like Walriichu did it differently)
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 13, 2016, 02:07:45 am
Yeah, that would be cool. Especially if you had an auto up loader to apps that then could use them as sprites. Or if you could somehow return the GROB data  for DIMGROB() :P
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 13, 2016, 06:03:02 am
An uploader could be nice, but then we might as well do the Walrii maker on the PC or web :P. On0calc the easiest way would be to get the user to manually copy/paste each frame from the emulator screenshot utility into an image software, although that wouldn't be convenient.
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 13, 2016, 11:56:36 am
Well if you had it on calc then you could just make the final GROB an AFile and then you wouldn't have to use  PC at all, what I have gathered from Tim Wessman is that GROBs are .png images so they are ready to be implemented in Apps ;)
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 14, 2016, 07:17:12 am
Do you mean AFiles can send images to the PC or make transfers easier?  There would still be the issue about animating the walrus sprite, though, since not everyone is aware that animated GIF makers that don't cost money actually exist.
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 15, 2016, 01:17:54 am
Well in a round about way you could transfer AFiles to your PC but you would have to drag and drop the whole app file from the connectivity kit to your file explorer and open up the directory where AFiles are kept, so yeah. But what I meant is that GROBs no matter if you are just making it without the help of AFiles will always be a png image. Meaning that you can create AFiles right on the calc and store GROBs to them without the use of a PC.

EDIT: Also in testing today I found that by creating matrices manually you decrease their size in RAM by 50% O.O I made one matrix with MAKEMAT() to be 100x199 (the max size for that command) and then I made one manually within a program the same size except the one made using my program was only 155KB instead of 311KB *.*. Here is the program I used to make the matrix manually:


MakeUserMat()
BEGIN
LOCAL Loop; //just a loop variable to use in loops :P
M1:=[[0,0],[0,0]]; //To make sure M1 is a matrix and not a vector and also to reset it's size
FOR Loop FOR 1 TO 100 DO
  M1(Loop,1):=0; //Remember matrix coordinates are in rows columns format ;)
END;
FOR Loop FOR 1 TO 199 DO
  M1(1,Loop):=0;
END;
END;
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 17, 2016, 04:55:24 pm
Hm that sounds like a bug. I know that on the 84+ a full matrix requires three times more RAM than the matrix takes in order to be stored (one copy for Ans, one copy for the storage and I think another copy in safe RAM or perhaps the program version?), but the matrix size is the same no matter how it was stored.


Nowadays I tend to avoid matrices altogether, though, because on the TI-84+CE they cannot be larger than 400 elements. I prefer using lists and some extra code.
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 18, 2016, 02:39:37 am
I would lime to not use matrices but it would just bee too hard (for my level and speedwise) and believe me I tried every single different idea I could think of for MinePrime. But I do think that it is a bug, you just have to make sure you quit properly so you won't leave another 290 or so KB in RAM <_<
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 18, 2016, 03:10:34 am
I didn't realize that lists were slower on the HP Prime. On the 84+ the speed difference is negligible. I hope that the bug won't cause memory leaks, though (that gets worse until you reboot)
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 18, 2016, 04:17:19 am
Well for lists it is more of a size and convenience thing, first they take up more space when storing the same amount of data, this is because they can have any data type stored in them. And with matrices you only have to reference them like this: M1(row,column).
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 18, 2016, 04:24:23 am
That sucks. I was sure they were smaller. Is there a way on the HP Prime to switch to integers by default so that each number only takes a few bytes?

That said, I guess matrices are fine as long as they can be of any size. I don't understand why they added an hard limit on the CE considering that calculator has 150 KB of RAM (which could hold matrices of 16500 elements fine). Maybe TI just got too many support questions asking why an ERR:MEMORY occurred when trying to store a 11 KB matrix despite having 24 KB of RAM.
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 18, 2016, 04:29:07 am
Quote from: DJ Omnimaga on May 18, 2016, 04:24:23 am
That sucks. I was sure they were smaller. Is there a way on the HP Prime to switch to integers by default so that each number only takes a few bytes?

That said, I guess matrices are fine as long as they can be of any size. I don't understand why they added an hard limit on the CE considering that calculator has 150 KB of RAM (which could hold matrices of 16500 elements fine). Maybe TI just got too many support questions asking why an ERR:MEMORY occurred when trying to store a 11 KB matrix despite having 24 KB of RAM.

No, I don't think you could do that with the Prime.

the biggest world size would boast ~296KB in the RAM Which should be fine but just make sure you exit the program without pressing ON (like I said before since it keeps it in RAM until the code is compiled again <_< ). If you have that much in a single variable it seems to slow down the calc...
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 19, 2016, 03:59:11 pm
So by exiting with ON it clears the RAM from temporary variables? What about GROB's? Do we still need to do the following at the start of every program?

DIMGROB_P(G1,1,1);
DIMGROB_P(G2,1,1);
DIMGROB_P(G3,1,1);
DIMGROB_P(G4,1,1);
DIMGROB_P(G5,1,1);
DIMGROB_P(G6,1,1);
DIMGROB_P(G7,1,1);
DIMGROB_P(G8,1,1);
DIMGROB_P(G9,1,1);
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 19, 2016, 06:55:52 pm
Well when you exit it doesn't clear the RAM from GROBs so yeah, you have to run that at the start of your programs. And also if you use LOCAL MyVar; to make global vars for your program it will not clear them once that program exits, but if you edit the source without running it will clear it, so you have to clear all large variables.
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 19, 2016, 07:01:26 pm
Wait, exiting programs doesn't clear local variables? Doesn't that defeat the point of local variables? ???
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 19, 2016, 08:54:28 pm
Nope, it doesn't clear them but you can't change them outside the program. Unless you use EXPORT MyVar; then it creates a new Home variable that you can access and modify out of the program. I am pretty sure it is a bug that it keeps them though, and this was also present in the previous OS so it is not an upgrade issue
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 19, 2016, 09:50:02 pm
I hope they fix that one day. Not that variables are big in general, but sometimes people might use incredibly large lists.
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 20, 2016, 12:05:25 pm
Or incredibly large matrices :trollface:
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 20, 2016, 06:32:14 pm
Yeah true. By the way what's the max size for matrices and strings?
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 20, 2016, 07:57:42 pm
The matrices cannot exceed 311 KB and the strings cannot exceed 65535 characters in length. The string is confirmed by people at HP Museum while the matrices are just from my testing...
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 21, 2016, 04:28:35 am
I see, thanks for the info. I think I would be fine with those limits for sure, unless one matrix element takes like 1 KB <_<
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 22, 2016, 01:42:18 am
Quote from: DJ Omnimaga on May 21, 2016, 04:28:35 am
I see, thanks for the info. I think I would be fine with those limits for sure, unless one matrix element takes like 1 KB <_<

I am not sure that is possible since you can only have numbers in matrices :P
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: DJ Omnimaga on May 22, 2016, 04:17:35 am
Well, sometimes I am skeptical, given how large the data for a 1x1 GROB is in source code format O.O
Title: Re: HP Prime and HP-PPL Statistics and useful tips and tricks
Post by: alexgt on May 23, 2016, 11:39:39 am
Very true :P