Author Topic: Hp Prime Questions and Help  (Read 18030 times)

0 Members and 1 Guest are viewing this topic.

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Hp Prime Questions and Help
« on: October 21, 2013, 10:45:39 pm »
I've made this new topic here, to share knowledge and ask questions about the HP Prime, It's language (Prime BASIC?), and ways to go about certain things.

For Ex.

I have a question (seriously), How would I go about drawing text, sprites, and other objects to the screen?


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 Questions and Help
« Reply #1 on: October 21, 2013, 11:41:32 pm »
Have you checked the on-calc help by the way? The HP Prime wiki could be useful too http://tiplanet.org/hpwiki/index.php?title=HP_Prime/HP-BASIC , although it's incomplete. Just go to the commands menus then when hovering over a command with the arrows, press the Help button. They all have the syntax there.

However, in case you already checked that and it didn't work, could you share what troubles you had (source code)?

Sprites can be rather tricky because of the format. You need to convert images to HP Prime data using one of the converters there: http://ourl.ca/19398 (my favorite is Tim Wessman's because it has a GUI, but I like Jim Bauwens' too). To create one 16x16 sprite the code would look like this:

DIMGROB_P(G1, 16, 16, {#200420002000200:64h ,#200020002000200:64h ,#200020002000200:64h ,#200420002000200:64h ,#2007FE0020003E0:64h ,#200420002004200:64h ,#4200020002006378:64h ,#2007FE002000200:64h ,#2007FE0020003E0:64h ,#200020002000200:64h ,#20003E002000200:64h , #2007FE002000200:64h ,#200020002000200:64h ,#4200000002000210:64h ,#20003E002000200:64h ,#200020063780200:64h ,#200000002007FE0:64h ,#2000000020003E0:64h ,#200020002000200:64h ,#200021002000200:64h ,#200000002007FE0:64h ,#2000210020003E0:64h ,#20002007FE00200:64h , #200020003E00200:64h ,#6378020002000200:64h ,#20003E002000200:64h ,#420002007FE00200:64h ,#6378020003E00200:64h ,#200020042000200:64h ,#20003E002000200:64h ,#200020002000200:64h ,#200020002000000:64h ,#2007FE003E00200:64h ,#7FE0020042000200:64h ,#200020002000200:64h , #200020002000000:64h ,#2007FE003E00200:64h ,#7FE0020002000200:64h ,#3E0020063780200:64h ,#200420002000200:64h ,#200020002000200:64h ,#200020002006378:64h ,#3E0020002000000:64h ,#200020002000200:64h ,#200020003E00200:64h ,#200020002007FE0:64h ,#2007FE002000000:64h , #200420002000200:64h ,#200020003E00200:64h ,#3E0021002007FE0:64h ,#2007FE002000200:64h ,#200020003E00200:64h ,#200420002000200:64h ,#3E0020002000200:64h ,#200420002000200:64h ,#200020003E00200:64h ,#200021063780200:64h ,#200020042000200:64h ,#4200020002000200:64h , #200021002000200:64h ,#200020002000200:64h ,#200020002000200:64h ,#200020002000200:64h ,#200020002000200:64h });


To display it somewhere on the screen you need to do something like BLIT_P(G0,100,100,116,116,G1,0,0,16,16);
« Last Edit: October 22, 2013, 12:12:48 am by DJ Omnimaga »

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: Hp Prime Questions and Help
« Reply #2 on: October 21, 2013, 11:44:31 pm »
Ok sweet that's really helpful. + I didn't know you could use the help section on the cmds. XD

Expect Abandoned for Hp Prime :P
« Last Edit: October 21, 2013, 11:44:48 pm by XiiR3CR34T10N »

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 Questions and Help
« Reply #3 on: October 21, 2013, 11:52:00 pm »
Oh also btw you can store as many sprites as you want in one GROB, but you can only store about 15 at once in one DIMGROB_P command. It's possible to have more than that by creating a massive GROB (for example, using DIMGROB_P(G2,16,1024); ) then creating one set of sprite in G1, copying it in G2, creating another in G1, copying it after the other, and so on.


As for transparency, for example if you use red, you should setup the 2nd GROB like this:
DIMGROB_P(G2,16,1024,RGB(255,0,0,128));

Basically it sets the background color to red, but transparent. Do not use White, though, else it won't work.


Here's some code example at http://ourl.ca/19698/362793 but I might use those sprites in a game.

As for Abandoned it would probably be possible, but try to keep your graphics small and have no rotation. It's best to start with smaller projects too in case, and experiment.
« Last Edit: October 21, 2013, 11:52:09 pm by DJ Omnimaga »

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: Hp Prime Questions and Help
« Reply #4 on: October 22, 2013, 01:15:03 am »
You lost me pretty quick. XD Anyway ya, I'm probably going to keep small sprites, finite worlds, no multiplayer, and no sprite rotation.

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 Questions and Help
« Reply #5 on: October 22, 2013, 02:53:49 pm »
Btw one trick to create small games is also to just use a 160x120 screen area with 8x8 sprites then once you updated the display content in a GROB/buffer, you just copy that buffer scaled up to twice its size. It causes some minor slowdowns, though. There is a rotation routine somewhere but it's slow, so to use rotated sprites you have to pre-render them before the game starts.

Offline Ryleh

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +2/-0
    • View Profile
Re: Hp Prime Questions and Help
« Reply #6 on: October 28, 2013, 09:25:19 am »
Can't help but feel this is a stupid question but what are you guys using to program in?
I'm just typing into the calculator directly through the connectivity kit in the most 'agnostic' way I can since it doesn't support all of the same symbols/input as the calculator (and vice-versa).

Additionally, are there any well defined resources further describing the language functions and their usage? A better explanation of the syntax would be particularly beneficial as that is what is holding me back the most. Any general help on how to approach programming on this thing would be great. Something tells me I'm doing something wrong if I have a dozen end statements at the end of some of my programs. Decent at C/C++(academic and extracurricular) but my TI-Basic was hack-ish at best(bulky and far from efficient). Started work on a cheat sheet but outside of the integer stuff, it is limited to what I can piece together from the 600-ish page manual.
Cheat sheet:
Spoiler For Spoiler:
########################################################################################################
   ____ ___  __  __ __  __    _    _   _ ____  ____ 
  / ___/ _ \|  \/  |  \/  |  / \  | \ | |  _ \/ ___|
 | |  | | | | |\/| | |\/| | / _ \ |  \| | | | \___ \
 | |__| |_| | |  | | |  | |/ ___ \| |\  | |_| |___) |
  \____\___/|_|  |_|_|  |_/_/   \_\_| \_|____/|____/
 
########################################################################################################
List of inputs:

A - ) Strings
   01a - ASC
   02a - ROTATE
   03a - MID
   04a - RIGHT
   05a - STRINGFROMID
   06a - LEFT
   07a - STRING
   08a - EXPR
   09a - DIM

B.) Drawing
   01b - C->PX
   02b - DRAWMENU
   03b - FREEZE
   04b - PX->C
   05b - RGB
   06b - Pixels
      - ARC_P
      - BLIT_P
      - DIMGROB_P
      - GETPIX_P
      - GROBH_P
      - GROBW_P
      - INVERT_P
      - LINE_P
      - PIXOFF_P
      - PIXON_P
      - RECT_P
      - SUBGROB_P
      - TEXTOUT_P
   7b - Cartesian
      - ARC
      - BLIT
      - DIMGROB
      - GETPIX
      - GROBH
      - GROBW
      - INVERT
      - LINE
      - PIXOFF
      - PIXON
      - RECT
      - SUBGROB
      - TEXTOUT

C.) Matrix
   01c. - ADDCOL
   02c. - ADDROW
   03c. - DELCOL
   04c. - EDIMAT
   05c. - REDIM
   06c. - REPLACE
   07c. - SCALE
   08c. - SCALEADD
   09c. - SUB
   10c. - SWAPCOL
   11c. - SWAPROW
D.) App Functions
   01d. - CHECK
   02d. - STARTAPP
   03d. - STARTVIEW
   04d. - UNCHECK
   05d. - VIEW

E.) Integer
   01e - BITAND
   02e - BITNOT
   03e - BITOR
   04e - BITSL
   05e - BITSR
   06e - BITXOR
   07e - B->R
   08e - GETBASE
   09e - GETBITS
   10e - R->B
   11e - SETBASE
   12e - SETBITS
   
F.) I/O
   01f - CHOOSE
   02f - EDITLIST
   03f - EDITMAT
   04f - GETKEY
   05f - INPUT
   06f - ISKEYDOWN
   07f - MOUSE
   08f - MSGBOX
   09f - PRINT
   10f - WAIT
   
G.) More
   01g - %CHANGE
   02g - %TOTAL
   03g - CAS
   04g - EVALLIST
   05g - EXECON
   06g - ->HMS
   07g - HMS->
   08g - ITERATE
   09g - TICKS
   10g - TIME
   11g - TYPE
########################################################################################################
  ____  ____   ___   ____ ____      _    __  __    ____ ___  __  __ __  __    _    _   _ ____  ____ 
 |  _ \|  _ \ / _ \ / ___|  _ \    / \  |  \/  |  / ___/ _ \|  \/  |  \/  |  / \  | \ | |  _ \/ ___|
 | |_) | |_) | | | | |  _| |_) |  / _ \ | |\/| | | |  | | | | |\/| | |\/| | / _ \ |  \| | | | \___ \
 |  __/|  _ <| |_| | |_| |  _ <  / ___ \| |  | | | |__| |_| | |  | | |  | |/ ___ \| |\  | |_| |___) |
 |_|   |_| \_\\___/ \____|_| \_\/_/   \_\_|  |_|  \____\___/|_|  |_|_|  |_/_/   \_\_| \_|____/|____/
 
########################################################################################################

H.) Block
   01h - BEGIN END
   02h - RETURN
   03h - KILL
   
I.) Branch
   01i - IF THEN
   02i - IF THEN ELSE
   03i - CASE
   04i - IFERR
   05i - IFERR ELSE

J.) Loop
   01j - FOR
   02j - FOR STEP
   03j - FOR DOWN
   04j - FOR DOWN STEP
   05j - WHILE
   06j - REPEAT
   07j - BREAK
   08j - CONTINUE

K.) Variable
   01k - LOCAL
   02k - EXPORT

L.) Function
   01l - EXPORT
   02l - VIEW
   03l - KEY


Looking to do the definition usage stuff later today. Wondering if there is already something along this vein before I up and do it myself. Mind the messed up ANSI words. The TI-Planet wiki thing doesn't seem to have much more then the drawing done.
« Last Edit: October 28, 2013, 11:58:49 am by Ryleh »

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 Questions and Help
« Reply #7 on: October 28, 2013, 02:01:34 pm »
I personally used the guide book, as well as the on-calc help and the HP Prime wiki on TI-Planet for reference. It did the job decently, but I had to ask on the forums for clarification. In general, for now it's best to ask on the forums if you can't find what you need.

Also I prefer programming using the connectivity kit. For weird symbols I always have some code containing them nearby that I can copy/paste from anyway. I sometimes use the emulator too, but the random crashes are annoying with the resulting progress loss and on the real calc, if my program code is very long in terms of width, typing is very slow.

Offline Ryleh

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +2/-0
    • View Profile
Re: Hp Prime Questions and Help
« Reply #8 on: October 28, 2013, 02:16:32 pm »
Didn't come to mind to manually enter the codes. I'll have to make a list of common things I use that don't display properly.

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 Questions and Help
« Reply #9 on: October 28, 2013, 03:15:17 pm »
Which ones do you use in particular by the way? I tend to only use the Sto character.

Offline Ryleh

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +2/-0
    • View Profile
Re: Hp Prime Questions and Help
« Reply #10 on: October 28, 2013, 03:52:43 pm »
Which ones do you use in particular by the way? I tend to only use the Sto character.
Tau(т), Pi(π), Theta(Σ) and that weird u with the front tail come to mind. Forgot to mention it but I am also typing out notes so sometimes I want the actual character.

I have a few more questions...

Are any of the following things possible:
-Programs with multiple drop downs (Concurrently)
-Program with multiple entry boxes where it doesn't need submitted(results are displayed as more information is added)
-Make it access the cas/traditional view where it calculates math normally but with acceptance for additional characters(who serve as their own variables, ex. 12m being 12E-3 or 12x10^3)
-Practically display drawn objects on the graphing view (or with similar functionality at least)
-Use of checkmark like stuff for checking

Would like to know ahead of time if any of these things are not possible to do for whatever arbitrary reason before I invest to much time in trying to do it that way. Understand there are workarounds to all of the above things but I'd like to do it as elegantly as possible since I'd like to work on making it as user-friendly as possible.



Here are some of the ideas I had on things I'd like to do(in no order of actual interest or likelihood of actually doing them):
-Resistor rating calculator(with drop downs for different colors/tolerance)
-Karnaugh Map Generator
-Boolean logic simplifier
-Ohm's Law solver
-Capacitor/Inductance solver
-Boolean truth table
-Circuit truth table
-KVL/KCL/Nodal Analysis
-General area for manually computing EE related stuff(more easily for less-well acquainted users of the calculator)
-IC searcher (means of searching for very specific IC chip names)


Thanks again in advance for any prior or future advice. :P
« Last Edit: October 28, 2013, 04:23:34 pm by Ryleh »

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: Hp Prime Questions and Help
« Reply #11 on: October 28, 2013, 07:19:16 pm »
I'm pretty sure that (Σ) is Sigma...
Isn't Theta (Θ)?

Anyway, I'm pretty sure that all of these would be entirely possible.
« Last Edit: October 28, 2013, 07:19:51 pm by XiiR3CR34T10N »

Offline Ryleh

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +2/-0
    • View Profile
Re: Hp Prime Questions and Help
« Reply #12 on: October 28, 2013, 09:18:22 pm »
I'm pretty sure that (Σ) is Sigma...
Isn't Theta (Θ)?

Anyway, I'm pretty sure that all of these would be entirely possible.

You're right on both accounts. Silly mistake on my end. x_x

Glad to hear you think those things are possible. Thanks.

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: Hp Prime Questions and Help
« Reply #13 on: October 28, 2013, 09:45:14 pm »
Been playing around with my prime for a bit. Although I should get back to my C# game. Does anyone know what "mouse" does? By the description it looks like it gives you touch variables in a list.

For example {x1,x2,originalx,originaly,type} for type the following include: drag, swipe, hold, press, etc.

I think this is enough to assume touch control is definitely programmable. So for anyone who is wondering...PROJECT ABANDONED PRIME IS A GO! ;D ;)
« Last Edit: October 28, 2013, 09:45:31 pm by XiiR3CR34T10N »

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 Questions and Help
« Reply #14 on: October 28, 2013, 10:39:33 pm »
I definitively think that the mouse command is for the touchscreen. And wow I didn't realize it also had complex commands such as drag and swipe O.O. It would make certain strategy games possible for sure. My only concern would be slowdowns resulting from AI if a strategy game has collision detection to take into account. Unless it was made as dumb as Warcraft 2 AI.


On a side note, anyone know if it's possible to permanently save lists and other kind of variables? I know that the calc has some lists vars but I heard that they get deleted when the calc is turned OFF.
« Last Edit: October 28, 2013, 10:41:40 pm by DJ Omnimaga »