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

HP Prime PPL language (split from birthday thread)

Started by Dream of Omnimaga, August 11, 2016, 07:58:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dream of Omnimaga

EDIT by DJ: Topic split from Birthday thread https://codewalr.us/index.php?topic=1529.0
Quote from: Travis on August 11, 2016, 07:45:37 PM
Thanks everyone. :) I decided to give the HP Prime a try, because it seems possible that I could create some nifty programs with good performance on it. Once I learn my way around, we'll see, provided I can get computer/calc transfer working.
Wow nice that you got a Prime. I need to start coding on it again. You can do amazing stuff that rivals some CE ASM and C games, in HP PPL.
  • 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

Travis

Yeah, I stayed up late last night reading through the programming section of the user guide, and the programming language looks like it should be capable enough. :) Graphics programming looks interesting, as the GROB functionality in general looks quite similar to that on the HP 50g, including the ability to do double-buffering and stuff, which is pretty cool. I never did a whole lot of graphics stuff on the 50g (just a tiny bit), but I'm fairly familiar with how it works and what's possible.

One thing that may take me some getting used to is the lack of a true directory structure/file system, and of course the ability to back up/archive data on an SD card, which is how I was able to dodge the whole "how am I going to connect this thing to Linux, and will the third-party Linux software work well?" issue with the 50g: The SD card is FAT, which has worked fine on Linux for ages. I wish they had made the Prime emulate a normal USB FAT disk for file transfer and such; that would have been very simple and universal and would have avoided the need for special PC communication software.

I'm also a bit underwhelmed with the program editor, to be honest. It seems rather lacking in functionality compared to the 50g's editor. Apparently there's no search or quick navigation like jumping directly to subprogram definitions (I fear that navigating large, complex programs is going to be painful), and it's not even indentation aware. But looking through the available commands, I see there does appear to be commands to read and write to the actual program sources, so maybe it would be possible to write a better on-calc program editor. ;)
  • Calculators owned: TI-81, TI-82, TI-85, TI-86, TI-89, TI-89 Titanium, 2 × HP 50g

Dream of Omnimaga

Oh, trust me, you'll be blown away by the language speed. I don't recommend updating to OS 10077 but apparently it has sprite opacity support. Previous OSes have no sprite opacity, but they're still very powerful. You can display your sprites at any zoom, on 9 graphic buffers and so on. I recommend displaying them on a small buffer at 100% zoom then displaying that buffer zoomed in to fit the screen. You could even make a 96x64 game if you wanted to. But the thing about this language is the speed. Here's a screenshot demonstrating the sprite/buffer scaling capabilities, where I scroll a background around, flash some text (all text is about 10 copies of the text because I wanted an outline) and displays the title logo in chunks at different zooms to create a wave effect:



The fade-in/out pixelating effects uses the buffer scaling capabilities. The only issue is that like with Z80 calcs, FOR instructions are slow it seems. A 20x15 tiles map will give you 15 FPS. But you can simply pre-render the current screen, then when you scroll around you only draw the edge that's missing.
  • 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

Travis

Quote from: DJ Omnimaga on August 12, 2016, 02:54:19 AMThe fade-in/out pixelating effects uses the buffer scaling capabilities. The only issue is that like with Z80 calcs, FOR instructions are slow it seems. A 20x15 tiles map will give you 15 FPS. But you can simply pre-render the current screen, then when you scroll around you only draw the edge that's missing.

Ah, neat. Is the 15 FPS you mention when trying to redraw everything every single frame (all 300 tiles and all sprites)? I was thinking about this and was imagining that with a scrolling tilemap, I'd render all tiles once and then only render an additional column or row (depending on scroll direction) just before it scrolls on screen, possibly using a back-buffer GROB one tile larger than the screen in each direction to do so. It sounds like this is what you're describing. I figure that'd indeed be a lot faster.

Cool.
  • Calculators owned: TI-81, TI-82, TI-85, TI-86, TI-89, TI-89 Titanium, 2 × HP 50g

Dream of Omnimaga

Yeah, redrawing 300 tiles every frame was done in 15 FPS. That is definitively more than enough, but of course for smoother gameplay you definitively want to use tricks as you mentioned. I never figured out how to do such scrolling routine, though.
  • 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

Travis

I haven't tried it myself before yet, but I think It's sort of similar to how a lot of games on old consoles like the NES worked, I think. They had pretty slow CPUs by today's standards (often even slower than the old Z80 calcs, I think), but even worse, they couldn't access video RAM at the same time as the video output hardware. The video hardware had to read it almost all of the time to send the signal to the TV (which required a constant 50/60 FPS depending on NTSC/PAL), and the game program only had just enough time between frames to update maybe a couple of rows of offscreen tiles at a time or something like that. In some games when there were too many things on the screen and they lagged, IIRC there would be graphical glitches if the CPU didn't finish updating video RAM in time before the controller started reading it again for the next frame. This happens in Zelda II and TMNT I, for instance (where the screen jumps up and down or the HUD flickers on and off during lag).

Thankfully, we don't have to worry about all that on the calcs :P

But anyway, in a platformer, for instance, you might have variables to keep track of the current X and Y scroll offset and add/subtract it when checking screen coordinates of the objects to figure out where on the screen they actually are while taking the scrolling in account. Or something like that. In my first games, I'll likely just have the scrolling happen either a screen or a tile at a time as an animation (either like Zelda I or in games like Final Fantasy where you move on a map only in tile increments, and nothing else happens during the actual scrolling), which should be easier to do.
  • Calculators owned: TI-81, TI-82, TI-85, TI-86, TI-89, TI-89 Titanium, 2 × HP 50g

Dream of Omnimaga

Yeah I would say that HP PPL power would allow you to at least make games that look like SNES material, without the extra chips some cartridges used. It's a compiled language IIRC, and is most likely not as efficient as C due to being proprietary and designed to run on a math engine, plus I don't know if the hardware accelleration features of the HP Prime rumors are founded. The NES supported mappers at least.

In any case, I would like to port GalagACE to the Prime at some point, to see how far I can enhance it before it slows down.
  • 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

Travis

I fooled around a little with a simple program that counts as fast as possible. Double-buffering definitely seems to be the way to go, even for fairly simple stuff. Screen updates are very smooth and flicker-free that way. Of course, it's even faster just writing text directly to the screen (G0), but not surprisingly it flickers like mad. :P Unfortunately, I think I see some evidence of tearing sometimes (I guess there's no way to sync blits to LCD refresh rate) but just being able to control when the screen updates is already a very important and powerful feature.

In response to IRC (I was AFK), I don't mind splitting this discussion. I was actually wondering if I was derailing the thread too much. :)
  • Calculators owned: TI-81, TI-82, TI-85, TI-86, TI-89, TI-89 Titanium, 2 × HP 50g

Travis

I just had to do it. I made a screen-inverting program that works pixel by pixel.

Not really, but I made something that isn't too far off (though a bit more useful). CONTOUR() is a very basic contour-type plotter that evaluates a function Z=F(X,Y) for every pixel and displays the Z value as a color. It's just a practice program, so it doesn't do a whole lot. On the calc it typically takes around a minute to graph a simple function in either grayscale or a rainbow-like spectrum. The last graph created is stored to G1 for further use. ENTER/ESC after graphing finishes returns to the screen for entering parameters (any other key can be used to brighten the backlight after it dims, for better viewing).

Warning: At least on my FW 8151 calc and the HP simulator, pressing ON to abort the program during graphing seems to lock up the OS and require a forced reboot with certain functions, like gcd() and lcm(). I don't know why. It might be best to wait for the program to finish, press ENTER/ESC to return to the input form, then use ESC to quit.

EXPORT XLO:=−10;
EXPORT XHI:=10;
EXPORT YLO:=−10;
EXPORT YHI:=10;
EXPORT ZLO:=−4;
EXPORT ZHI:=4;
EXPORT XPHI:=GROBW_P(G0);
EXPORT YPHI:=GROBH_P(G0);
EXPORT ZF:='SIN(X*Y)-COS(X)/TAN(Y)';
EXPORT PALETTE:=1;


EXPORT GETCOLOR(ZVAL)
BEGIN
ZVAL:=(ZVAL-ZLO)/(ZHI-ZLO)*256;
ZVAL:=MAX(MIN(IP(ZVAL),255),0);
CASE
  IF PALETTE==2 THEN
   LOCAL ZNORM:=IP((ZVAL MOD 51.2)*(256/51.2));
   CASE
     IF ZVAL<52 THEN RETURN RGB(0,0,ZNORM); END;
     IF ZVAL<103 THEN RETURN RGB(0,ZNORM,255); END;
     IF ZVAL<154 THEN RETURN RGB(0,255,255-ZNORM); END;
     IF ZVAL<205 THEN RETURN RGB(ZNORM,255,0); END;
     IF ZVAL<256 THEN RETURN RGB(255,255-ZNORM,0); END;
     DEFAULT
   END;
  END;
  DEFAULT
   RETURN RGB(ZVAL,ZVAL,ZVAL);
END;
END;

EXPORT GETERRCOLOR()
BEGIN
CASE
  IF PALETTE==2 THEN
   RETURN RGB(255,255,255);
  END;
  DEFAULT
   RETURN RGB(255,0,0);
END;
END;

EXPORT PLOT(XSTART,XSTOP,XSTEP,
            YSTART,YSTOP,YSTEP)
BEGIN
LOCAL XPX,YPX;
FOR YPX FROM YSTART TO YSTOP STEP YSTEP DO
  Y:=((YPHI-YPX)/YPHI)*(YHI-YLO)+YLO;
  FOR XPX FROM XSTART TO XSTOP STEP XSTEP DO
   X:=(XPX/XPHI)*(XHI-XLO)+XLO;
   IFERR Z:=EVAL(ZF);
   THEN PIXON_P(G0,XPX,YPX,GETERRCOLOR());
   ELSE PIXON_P(G0,XPX,YPX,GETCOLOR(Z));
   END;
  END;
END;
END;

EXPORT CONTOUR()
BEGIN
WHILE 1 DO
//Get function and range from user
IF NOT INPUT({
  {ZF,[8],{15,84,0}},
  {PALETTE,{"Grayscale","Spectrum"},
   {15,84,1}},
  {XLO,[0],{15,41,3}},
  {XHI,[0],{58,41,3}},
  {YLO,[0],{15,41,4}},
  {YHI,[0],{58,41,4}},
  {ZLO,[0],{15,41,5}},
  {ZHI,[0],{58,41,5}}},
  "Simple countour plotter",
  {"Func:","Color:",
   "X Rng:","","Y Rng:","","Z Rng:",""},
  {"Graph function",
   "Palette used for graph",
   "Minimum X value","Maximum X value",
   "Minimum Y value","Maximum Y value",
   "Minimum Z value","Maximum Z value"}
) THEN BREAK; END;

LOCAL XPX,YPX;

//Plot
RECT_P();
PLOT(0,XPHI,2,0,YPHI,2);
PLOT(1,XPHI,2,0,YPHI,2);
PLOT(0,XPHI,1,1,YPHI,2);

// Save last graph to G1 and wait
DIMGROB_P(G1,XPHI,YPHI);
BLIT_P(G1,G0);
WHILE 1 DO
  LOCAL K:=WAIT(−1);
  IF TYPE(K)==0 THEN
   IF K==4 OR K==30 THEN BREAK; END;
  END;
END;
END;

END;
  • Calculators owned: TI-81, TI-82, TI-85, TI-86, TI-89, TI-89 Titanium, 2 × HP 50g

Dream of Omnimaga

Hm interesting. I was actually curious about how long it would take to invert every pixel one by one on a real calculator. Given how fast the OS is, I thought it might be instant. What I would like to do at some point is create a different sprite format (maybe stored instrings) that is similar to CSE/CE xLIBC or Sprites 3.3, where I can change the sprites palette as I see fit. That way I would no longer need to convert my sprites three or four times if I decide to develop a multiplatform game or port an old one.

By the way I wonder if drawing to a different GROB than 0 then copying the final result over to the main screen is faster?
  • 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

Travis

Quote from: DJ Omnimaga on September 02, 2016, 02:58:48 AM
By the way I wonder if drawing to a different GROB than 0 then copying the final result over to the main screen is faster?

I haven't tried yet, but I'm guessing it wouldn't be fast enough to make up for not being able to see anything at all on the screen until it's done. Wouldn't hurt to do a test, though.

Unfortunately I haven't done much with the Prime lately, partly because the last few days I've been busy trying to replace a HDD in my computer that might be failing and having a lot of technical difficulties in the process, and because the HP Connectivity software I was using on an old Vista laptop suddenly decided to stop working (crashes every time I try to connect), making it impossible to back up the calculator. I don't have much motivation to do any significant work on a platform if I can't back up things, especially one that's known to have data-loss issues and bugs.

Maybe if I'm lucky I can get debrouxl's libhpcalcs working on my Linux box and be able to continue backing up that way.
  • Calculators owned: TI-81, TI-82, TI-85, TI-86, TI-89, TI-89 Titanium, 2 × HP 50g

Dream of Omnimaga

I am late but I hope your HDD replacement went fine and without data loss, especially your calculator stuff. >.< As for the connectivity kit software issues, you might need to ask support on MoHPC forums or make a separate topic about the issue.

That said, regarding data losses, HP released a new firmware and apparently it's more stable, but installing it reformats the calc sometimes.
  • 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

Travis

No data loss, fortunately. I've always been pretty aggressive about backups, which has helped me lose very little computer data over my life up to this point. It was pretty frustrating, though, because I kept having problems for no apparent reason. Ever since I put in one of the new drives, my Linux kernel occasionally crashes while writing to it now, which never happened before, and I still haven't managed to track it down yet. (It's been a few days now since it last happened.) On top of that, I accidentally broke my running system's bootloader while trying to move the OS to the SSD, so I was left with no bootable OSs (and ran into some weird complications trying to fix it that I never had to deal with before). So that meant several hours of booting from a Linux USB stick and trying to manually fix it from the terminal and booting a million times before finally getting it working. Given that this is my only primary computer, every time I have to do that, it results in downtime and my being in a really bad mood for a while. :P And then there was some other unrelated crap with the OS that happened to crop up at the same time (even though I had already run out of patience long by that point). So it took me about a full week instead of the expected couple of days to get back up and running.

But the good news is, I eventually got my system to boot again on the SSD and the original HDD. (Even though I don't even need the old HDD now, I managed to fix the bootloader on it anyway. :P Maybe the knowledge will help next time this happens.) And I was amazed with the SSD. Instead of 2 or 3 minutes, my whole system boots in something like 15–20 seconds, not including the BIOS screen and the time it takes me to enter passwords. :D

Also, HP did put out a new OS as you said, and also a new HP Connectivity Kit version, and this fixed my issues (the Connkit crashing was an issue a lot of people were having), so I can back up again. I was able to back up, upgrade the calc, and restore the backup without incident (as they warned, this update did reformat everything). So it looks like I'm back in business. Also, it looks like they added a backup feature where you can save backups on the calc itself, which is nice. Of course, I'll be backing up both on the calc and the computer as usual. ;)
  • Calculators owned: TI-81, TI-82, TI-85, TI-86, TI-89, TI-89 Titanium, 2 × HP 50g

Dream of Omnimaga

That's good. Some people don't learn even after 6-7 data losses. >.< Too bad you had issues with your drives and OS installs, though.

Also I'm glad that the new HP Connectivity Kit works for you now. I wonder if it also fix compatibility issues with Windows XP, Mac and Linux?
  • 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