Author Topic: [HP Prime] Tunnel update! (now running at 90 FPS!)  (Read 21271 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
[HP Prime] Tunnel update! (now running at 90 FPS!)
« on: August 07, 2013, 04:20:39 pm »
I saw a mandelbrot program a while ago somewhere that is from an HP Prime BASIC program, which left the impression that we could use colors inside programs. However, I haven't figured out how to do it because the manual doesn't explain how, other than the four shades of gray

TEXTOUT_P(text [ ,G], x, y [ ,font, c1, width, c2])

c1 is basically the text color. However, no matter the colors I choose, the text and background stays black and to not have a backgroud I have to not specify c2. Am I doing something wrong or is it a newly introduced bug that wasn't in the version used for the mandelbrot program? ???

P.S: An HP forum section would be nice.
« Last Edit: December 03, 2013, 11:08:51 pm by DJ Omnimaga »

Offline bb010g

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 428
  • Rating: +22/-1
  • I do stuff
    • View Profile
    • elsewhere on the net
Re: [HP Prime] Help using color in programs (other than grayscale)
« Reply #1 on: August 07, 2013, 04:26:19 pm »
You can give a RGB[A] value to drawing functions. For example, you can do this for a colored hello world:
Code: [Select]
EXPORT hello_world()
BEGIN
RECT();
TEXTOUT_P("Hello World!",50,50,0,RGB(0,136,204));
FREEZE;
END;
The commands have changed. Look through the help while in the editor. It's amazing.
« Last Edit: August 07, 2013, 05:12:54 pm by bb010g »
Arch Linux user
Haskell newbie | Warming up to Lua | Being dragged into C++
Calculators: HP 50g, HP 35s, Casio Prizm, TI-Nspire CX CAS, HP 28s, HP Prime, Mathematica 9 (if that counts)
π: 3.14...; l: 108; i: 105; e: 101; l+i+e: 314
THE CAKE IS A LIE IS A PIE

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: [HP Prime] Help using color in programs (other than grayscale)
« Reply #2 on: August 07, 2013, 04:32:32 pm »
bb010g wrap tour code with [ code][ /code] ;)

Code: [Select]
EXPORT hello_world()
BEGIN
RECT();
TEXTOUT_P("Hello World!",50,50,0,RGB(0,136,204));
FREEZE;
END;

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [HP Prime] Help using color in programs (other than grayscale)
« Reply #3 on: August 07, 2013, 04:35:01 pm »
Wait do you mean there's on-calc help? O.O I was actually checking the PDF file at C:\Program Files (x86)\Hewlett-Packard\HP Prime Virtual Calculator\User_Guide_EN.pdf lol. Thanks btw. :)

I guess it might be a good idea to notify HP about the misleading HP Prime manual in the emulator folder, in case they release it as it is when the calc comes out and some people decide to use it. Maybe they just replaced 39gII screenshots with Prime ones without bothering about changing the rest. The scary part is that this is supposedly the official emulator release, so I hope that the calc won't come with that version of the PDF.

Anyway that works now, thanks :D (changed the code a little bit)

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [HP Prime] Help using color in programs (other than grayscale)
« Reply #4 on: August 07, 2013, 04:38:21 pm »
Cool! Nice to see color text working. :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [HP Prime] Help using color in programs (other than grayscale)
« Reply #5 on: August 07, 2013, 06:07:50 pm »
Yeah I was worried for a second there. I am still a little annoyed at the width command, though, since it can make it annoying to display long text. However I guess you just have to set the width very high (such as 320 px) and it solves your issues.

What intrigues me are the binary stuff I saw somewhere, because I am curious if we can actually store data in hex or bin then re-use it later for multiple purposes (such as displaying plenty of little pixels or squares to form a sprite/image), rather than having to store our data in a list or something (which are large)?

EDIT: Here's a little test with rectangles, although the emulator runs about 9E999 times faster than the calc, so I had to add extra slowdowns so we can see something. At the end of the screenshot, after modifying some values, the various rectangles display at various locations.

Assuming that the calc display is the same speed as the 39gII or a bit faster, then using rectangles for graphics will most likely rival Nspire Lua speed to a certain extent.

Now to find an efficient way to display Mario...
« Last Edit: August 07, 2013, 06:41:52 pm by DJ Omnimaga »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [HP Prime] Color Tunnel clone (formerly color usage help thread)
« Reply #6 on: August 08, 2013, 01:36:01 am »
UPDATE: My Tunnel 39gII game has been ported to the HP Prime, but first, I need someone who got the actual calculator (not the emulator) to try the code or the program on their calc, to see if it's too slow or too fast and tell me. Maybe make a video if you can so it is easier for me to help you adjust the speed. :P

Spoiler For "Entire Code":
Quote
EXPORTTunnel()
BEGIN
1->C;
0->P;
100->Y;
20->T;
128->L;
0->L1(512);
FOR Z FROM 0 TO 16 DO
INT(RANDOM(100))->L1(2*Z+1);
60-INT(RANDOM(4))->L1(2*Z+2);
END;
RECT_P(0,0,319,219,RGB(30,100,255),RGB(30,100,255));
RECT_P(0,35,319,219,RGB(0,100,0),RGB(0,100,0));
FOR Z FROM 0 TO 10 DO
TEXTOUT_P("Score:",Z,0,7,RGB(15*Z+100,155-(10*Z),0),250);
TEXTOUT_P("Tunnel Prime",122+Z,0,7,RGB(255-(18*Z),10*Z+99,0),250);
END;
FOR Z FROM 0 TO 4 DO
LINE_P(0,Z+35,319,Z+35,RGB(0,20*Z,0));
END;
WHILE Y>0 DO
FOR Z FROM 0 TO 15 DO
FOR U FROM 0 TO 19999 DO
END;
C+1->C;
IF C>16 THEN
1->C;
END;
L1(2*C+2)->O;
L1(2*C+1)->Q;
RECT_P(20*Z,40,20*Z+19,O,RGB(0,50+Q,0),RGB(0,50+Q,0));
RECT_P(20*Z,O,20*Z+19,O+L,RGB(100+Q,130,50),RGB(100+Q,130,50));
RECT_P(20*Z,O+L,20*Z+19,246,RGB(0,50+Q,0),RGB(0,50+Q,0));
IF Z=0 THEN
RECT_P(0,Y,8,Y+12,RGB(0,0,0),RGB(150,150,255));
RECT_P(2,Y+4,14,Y+8,RGB(0,0,0),RGB(255,0,0));
IF Y<O OR Y+12>O+L THEN
-9->Y;
END;
END;
END;
TEXTOUT_P(P,70,2,6,RGB(0,0,0),200,RGB(50,100,255));
TEXTOUT_P(P,72,2,6,RGB(5,255,255));
P+1->P;
L1(2*C+2)->S;
INT(RANDOM(100))->U;
S+INT(RANDOM(30)-15)->Ans;
IF Ans<45 THEN
45->Ans;
ELSE
IF Ans>213-L THEN
213-L->Ans;
END;
END;
C+1->C;
IF C>16 THEN
1->C;
L-1->L;
END;
Ans->L1(2*C+2);
U->L1(2*C+1);
Y-(5*ISKEYDOWN(2))+(5*ISKEYDOWN(12))->Y;
END;
FOR Z FROM 0 TO 5 DO
INVERT();
FOR Y FROM 0 TO 999 DO
END;
END;
RECT_P(0,15,256,126,0,0);
MSGBOX("SCORE:"+P,1);
END;

In the code, you'll see the following:

Code: [Select]
FOR U FROM 0 TO 19999 DO
END;

Just change the 19999 to something smaller or remove it completely to speed up the program.

Screenshot and download below. If you got the HP Prime emulator, close it, then copy the hpprgm file in C:\Users\DJOmnimaga\AppData\Roaming\HP_Prime or whatever is your application data directory.
« Last Edit: September 13, 2013, 01:01:36 am by DJ Omnimaga »

Offline critor

  • Editor
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2079
  • Rating: +439/-13
    • View Profile
    • TI-Planet
Re: [HP Prime] Color Tunnel clone (formerly color usage help thread)
« Reply #7 on: August 08, 2013, 02:10:33 pm »
Just tested DJ_O's tunnel on the HP-Prime DVT prototype, with the wait-loop removed.

It's faster than flashes! :P


Prepare to include lots of wait-loops in your programs :P
« Last Edit: August 08, 2013, 02:10:50 pm by critor »
TI-Planet co-admin.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [HP Prime] Color Tunnel clone (formerly color usage help thread)
« Reply #8 on: August 08, 2013, 02:19:58 pm »
OMG that is fast. *.*
* Streetwalker wants this calc NAOWZ

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [HP Prime] Color Tunnel clone (formerly color usage help thread)
« Reply #9 on: August 08, 2013, 05:29:44 pm »
Wow, that's fantastic! I think I like it without the wait loops. That's like around the speed of ASM tunnel games on the z80 series. :D

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Re: [HP Prime] Color Tunnel clone (formerly color usage help thread)
« Reply #10 on: August 08, 2013, 05:43:19 pm »
Yeah I was shocked at how fast it ran. This means even better looking graphics could be used in games. :D

Thanks for the vid critor btw :)

Also although the game is fast, it seems more fun to play since the tunnel started really large, so you won't die within the first picosecond of gameplay.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [HP Prime] Color Tunnel clone (formerly color usage help thread)
« Reply #11 on: August 08, 2013, 05:47:59 pm »
This thing is faster than light. Now add assembly suport and give it to xeda and we will rule the world.

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [HP Prime] Color Tunnel clone (formerly color usage help thread)
« Reply #12 on: August 08, 2013, 06:00:37 pm »
Lol if ASM support is added, I bet that we'll have a Nintendo 64 emulator or something. I would like some exclusives, though, because the Nspire got emulators early and this pretty much killed the Nspire dev scene (since people saw no point in making new games when hundreds were already available). Still, ASM would be cool, though.

Also here's a smaller screenshot that runs at the real calc speed:

Offline timwessman

  • LV3 Member (Next: 100)
  • ***
  • Posts: 94
  • Rating: +32/-0
    • View Profile
Re: [HP Prime] Color Tunnel clone (formerly color usage help thread)
« Reply #13 on: August 08, 2013, 06:12:15 pm »
Prepare to include lots of wait-loops in your programs :P

Just an FYI - you can just put WAIT(<sec_value>) and wait for specified second value.

The commands have changed. Look through the help while in the editor. It's amazing.

Thanks! I really hoped it would be useful. You basically have about 30% of the 600+ page manual in there I estimate. The goal was that anywhere you are, pressing HELP would bring up useful stuff.

TW

TW
« Last Edit: August 08, 2013, 11:42:52 pm by timwessman »
TW

Although I work for the HP calculator group, the comments and opinions I post here are my own.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [HP Prime] Color Tunnel clone (formerly color usage help thread)
« Reply #14 on: August 08, 2013, 06:21:19 pm »
Hey timwessman, welcome to Omnimaga. If you have a quick thought to add, please use the "modify" button rather than add another post.