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

Porting TI-BASIC to HP PPL

Started by gogogoluke, January 06, 2016, 07:41:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gogogoluke

I was porting some code to my new HP Prime, but I ran into a problem. I cannot find an alternative to the code "B》dim(LZ)", as it produces the error "Invalid input". What is a good alternative to setting the size of a list (or matrix) from a variable?

Entire TI-BASIC code (For context, nobody port this for me):
[spoiler]C-1》C

Prompt B

B》dim (LZ)

B》dim (LPOKE)

Prompt B

If B=1

Then

Prompt B

Fill (B, LPOKE

Fill (1, LZ)

0》C

End

dim (LPOKE》B

While 1

Lbl 0

[[1,0,3,1][4,3,10,4] [15,10,5,0][12,11,15,10][20,11,10,8][17,16,17,4][20,15,20,19]]》[B]

C+1》C

If C=B+1

1》C

If LZ(C)=2

Then

iPart (rand×4》D

If D≠0

Then

1》LZ(C)

Disp "GET UP"

Disp C

End

Goto 0

End

Pause

ClrHome

0》H

If LPOKE(C)≤0

Goto 0

While H<B and B≤14

H+1》H

Disp LPOKE(H)

If B<7 and LZ(H)=2

Output(H,12,"F

End

0》H

While H<B-7 and B≤14 and B>7

H+1》H

Output(H,1,LPOKE(H)

If LZ(H)=2

Output(H,5,"F

End

Output(5,8,C

If B>7 and B≤14

B-7》H

While H<B

H+1》H

If LZ(H)=2

Output(H-B+7,12,"F

End

C》D

While D=C or LPOKE(D)≤0

Prompt D

End

ClrHome

If LZ(D)=1

Disp "STANDING"

If LZ(D)=2

Disp "FALLEN"

Pause

ClrHome

Disp "1:POKE"

Disp "2:JAB POKE

Disp "3:FOOT POKE"

Disp "4:POWER POKE"

Disp "5:SOLE POKE"

Disp "6:SHANK POKE"

Disp "7:FALCON POKE:

0》A

While A<7

0》H

A+1》A

While H<2

H+1》H

Output(A,11+2H,[B](A,H+2(LZ(D)-1))

End

End

Prompt E

iPart(rand*20+1》F

Disp F

0》G

If [B](E,2LZ(D))≥F

-1》G

If [B](E,2LZ(D)-1)≤F

1》G

If G=-1

Then

Disp "FALLEN"

2》LZ(C)

End

If G≤0

Goto 0

[[6,0][6,3][6,5][8,10][10,8][60,0][30,40]]》[B]

Disp "SUCCESS"

Disp "DAMAGE:"

iPart(rand*[B](E,1))+[B](E,2)+1》H

LPOKE(D)-H》LPOKE(D)

Disp H

Pause

Goto 0
[/spoiler]
  • Calculators owned: HP Prime, TI-84CSE
HP Prime, TI-84+CSE
Former Minecraft server owner
HP Prime enthusiast.

Dream of Omnimaga

Heya gogoluke and welcome to the forums. I don't remember what is the exact syntax to set a list dimension, but one trick I found that worked was to set a value to the highest list element you wanted.

For example, in Tunnel, I wanted my list to be 512 elements, so I just stored 0 in element 512 and it set the list dimension for me (or maybe it set it to 513? I forgot if lists start at 0 or 1 in HP PPL). That trick doesn't work if you want to set the list to a lower dimension afterwards, though (it only works upwards).

0►LZ(B);

(I actually wish that there was a TI-BASIC interpreter written in HP PPL, so that no porting would have been necessary, but since that doesn't exist yet)

Perhaps @alexgt might know if there is an actual dim command on the HP Prime?
  • 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

gogogoluke

Thanks, and I wish that there was an interpreter too, would be a lot faster than manually porting all of my programs. There is a dim function, but it appears to only report list/matrix dimensions, not set them. Lists are started at 1 in Non-CAS mode, but in CAS it starts at 0. On another note, what is the alternate for FILL(1,LZ)? (The game keeps track of HP via lists)
  • Calculators owned: HP Prime, TI-84CSE
HP Prime, TI-84+CSE
Former Minecraft server owner
HP Prime enthusiast.

Dream of Omnimaga

Hm interesting that HP would let us view dimensions, but not set them. That seems rather limiting when it's like one of the most fundamental features of lists and matrices in maths. I don't exactly remember if there is a FILL command, but since HP PPL runs so fast, you can probably fill the elements one by one via a FOR loop and it will almost be instant.
  • 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

gogogoluke

I was hoping that wasn't the case, but at least it will be fast. I'm not filling insane amounts of list items anyways, so it shouldn't be a problem even if it were TI-BASIC.
  • Calculators owned: HP Prime, TI-84CSE
HP Prime, TI-84+CSE
Former Minecraft server owner
HP Prime enthusiast.

alexgt

Use the MAKELIST(Expr,Var,Start,End) command :P

Or I can make a program for UtilPack ;)
  • Calculators owned: Ti-84+, Ti-Nspire, Hp Prime, Broken HP Prime, HP 48SX

Dream of Omnimaga

Ideally it would be best for him to use standalone solutions for now, since UltiPack dev is stalled for now. But thanks for the command. Does that set his list dimension alex?
  • 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

alexgt

yep Expr is the equation that you want evaluated (or just put zero in there if you want it to be a fresh list). Var is the variable you want to be a list and then just put 1 for the start and the DIM you want for End ;)
  • Calculators owned: Ti-84+, Ti-Nspire, Hp Prime, Broken HP Prime, HP 48SX

gogogoluke

Thank you. Do you happen to know of an alternative to output()? It appears to not exist for HP Prime.
  • Calculators owned: HP Prime, TI-84CSE
HP Prime, TI-84+CSE
Former Minecraft server owner
HP Prime enthusiast.

Dream of Omnimaga

No, but there is an alternative to Text(), which is TEXTOUT_P() . Also Instead of ClrHome or ClrDraw you can use RECT_P(#FFFFFF).
  • 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

alexgt

You can use some maths and take advantage of TEXTOUT_P(), like what DJ said. all of the characters except some special chars take up the same amount of pixels if that helps ;)
  • Calculators owned: Ti-84+, Ti-Nspire, Hp Prime, Broken HP Prime, HP 48SX

Dream of Omnimaga

Wait, HP PPL text is monospace? O.O I thought it wasn't. That's good to know, because on the 83+ text on the graph screen wasn't.
  • 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

alexgt

Well, at least for the built in program editor it is, but I am pretty sure it is also monospaced in regular TEXTOUT_P() functions but I haven't needed it to be so I haven't tested it.
  • Calculators owned: Ti-84+, Ti-Nspire, Hp Prime, Broken HP Prime, HP 48SX

Strontium

Last I tried doing something with text on the HP Prime, the text was definitely not monospaced. Unless something has changed since then.
  • Calculators owned: TI Nspire CX, HP Prime
  • Consoles, mobile devices and vintage computers owned: NES

alexgt

really?! it must be only in CAS, Homeview, NOtes, and the Editor because I know they are in there.
  • Calculators owned: Ti-84+, Ti-Nspire, Hp Prime, Broken HP Prime, HP 48SX

Powered by EzPortal