in discussion Programming & Design / TI-83/84/+/SE Programming » How do I take an element from a list and put it in a variable?

Thanks!

- Membership
- Editing Pages
- Site Information
- Related Sites

I posted my question here on stack overflow: stackoverflow....

(by Dragon_Hatcher 08 Aug 2020 23:38, posts: 1)

(by Dragon_Hatcher 08 Aug 2020 23:38, posts: 1)

Because the page is deleted. Re-create the page and try again. Copy and paste the description.

(by Bio_Hazard1282_rPi3 08 Aug 2020 20:31, posts: 2)

(by Bio_Hazard1282_rPi3 08 Aug 2020 20:31, posts: 2)

I'm trying to write a program and I need to transfer elements from a list to variables.

(by Proante2007 08 Aug 2020 15:38, posts: 3)

(by Proante2007 08 Aug 2020 15:38, posts: 3)

Wow… That helps a ton! Thank you a lot for explaining all of this to me! I have a better...

(by CalcNerd 06 Aug 2020 14:39, posts: 8)

(by CalcNerd 06 Aug 2020 14:39, posts: 8)

Recent Threads

(Started 08 Aug 2020 23:38,
Posts: 1)

(Started 08 Aug 2020 15:38,
Posts: 3)

(Started 03 Aug 2020 04:57,
Posts: 1)

(Started 02 Aug 2020 03:06,
Posts: 4)

(Started 01 Aug 2020 23:55,
Posts: 8)

(Started 30 Jul 2020 16:53,
Posts: 1)

(Started 29 Jul 2020 14:05,
Posts: 1)

(Started 29 Jul 2020 14:03,
Posts: 2)

(Started 25 Jul 2020 00:56,
Posts: 2)

(Started 24 Jul 2020 03:51,
Posts: 2)

(Started 23 Jul 2020 22:57,
Posts: 7)

(Started 23 Jul 2020 20:00,
Posts: 2)

**CHAR**- → ⸤ ⁻
- × ÷ ±
- √ Σ ≠
- ≥ ≤ π
- Δ χ ▶
- ֿ¹ ² ³
- L₁ L₂ L₃
- L₄ L₅ L₆
- ≅ ℕ º
- θ ∠ ∞
- ♦ ⇧ ∫
- ∏ ©

Recent Forum Posts

Proante2007 09 Aug 2020 10:41

in discussion Programming & Design / TI-83/84/+/SE Programming » How do I take an element from a list and put it in a variable?

in discussion Programming & Design / TI-83/84/+/SE Programming » How do I take an element from a list and put it in a variable?

Thanks!

Re: How do I take an element from a list and put it in a variable? by Proante2007, 09 Aug 2020 10:41

Dragon_Hatcher 08 Aug 2020 23:38

in discussion Programming & Design / Assembly Programming » Question about registers

in discussion Programming & Design / Assembly Programming » Question about registers

I posted my question here on stack overflow: stackoverflow. com/questions/63320698/when-using-z80-asm-is-there-a-difference-between-hl-and-bc-de

Bio_Hazard1282_rPi3 08 Aug 2020 20:31

in discussion General Discussion / Wiki Page Discussions » THERE IS NO GAME/ V 0.0.2

in discussion General Discussion / Wiki Page Discussions » THERE IS NO GAME/ V 0.0.2

Because the page is deleted. Re-create the page and try again. Copy and paste the description.

𝔹𝕚𝕠_ℍ𝕒𝕫𝕒𝕣𝕕𝟙𝟚𝟠𝟚

`Discord server is no longer available. Reason: Deleted`

Re: Wiki wouldnt let me upload a .zip or a group for this, by Bio_Hazard1282_rPi3, 08 Aug 2020 20:31

Bio_Hazard1282_rPi3 08 Aug 2020 20:28

in discussion Programming & Design / TI-83/84/+/SE Programming » How do I take an element from a list and put it in a variable?

in discussion Programming & Design / TI-83/84/+/SE Programming » How do I take an element from a list and put it in a variable?

List(element)->Variable

```
L1(1)->E
L1(2)->D
```

𝔹𝕚𝕠_ℍ𝕒𝕫𝕒𝕣𝕕𝟙𝟚𝟠𝟚

`Discord server is no longer available. Reason: Deleted`

Re: How do I take an element from a list and put it in a variable? by Bio_Hazard1282_rPi3, 08 Aug 2020 20:28

Proante2007 08 Aug 2020 15:38

in discussion Programming & Design / TI-83/84/+/SE Programming » How do I take an element from a list and put it in a variable?

in discussion Programming & Design / TI-83/84/+/SE Programming » How do I take an element from a list and put it in a variable?

I'm trying to write a program and I need to transfer elements from a list to variables.

CalcNerd 06 Aug 2020 14:39

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

Wow… That helps a ton! Thank you a lot for explaining all of this to me! I have a better grasp on it now! I also see why it is very important for the order of operations now in the expressions (I sort of forgot about that they would apply here…). Your help has been awesome! Also, I have a YouTube channel where I show off programs. I was wondering if you would like a shoutout for helping me? You have been very very very very helpful! You not only helped me with the code but went out of your way to explain it to me! Thank you for all of your help!!!!!

Trenly 05 Aug 2020 23:35

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

You are mostly correct; I'll break them both down below.

Let me know if you still have questions, I know my explanations are not always the easiest to follow

CalcNerd 05 Aug 2020 22:24

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

I am trying to say what I think is happening. I might be totally wrong on some things… :)

I hope that you can understand what I am writing. If not I can rephrase things.

Thank you A TON for all of your help! It means a lot to me!

If (K=23)(([B](Y,X)=2)+Jnot([B](Y,X):Then

If (K=23)

This basically (I think) is the triggering statement because it will "give" a one if the delete key is pressed. Otherwise, the whole statement is 0.

(([B](Y,X)=2)+Jnot([B](Y,X):Then

First off, the statement is checking to see if the character's position is equal to two in [B]. J is then being added. J is also being multiplied by not([B](Y,X)=0. This statement (I think) is to check if [B](Y,X) is equal to two or to zero and then adding K if it is 2. I think all that the not is doing is putting an equal to 0 at the end of the statement, but it saves a few bytes in the long run (without the closing parenthesis). Somehow it also allows for the toggle capability, but I am unsure how that works.

If (K=105)not([B](Y,X)not([A](Y,X:1→[B](Y,X

I feel like I have a better grasp on what this statement does. It first checks to see if K is equal to enter. It then checks to make sure that at Y,X In [B] that it is equal to zero and that Y,X in [A] is also equal to zero. If it is all zero it then stores 1 into [B] at Y,X.

Trenly 05 Aug 2020 12:58

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

All that code does is check if any of those keys have been pressed. They can be in any order, but I typically put them in groups as to how they are handled. So I usually put movement, then clear and enter, and then any additional action keys.

Some people use max( instead of sum( too, but I prefer sum. Here is how the command gets processed:

```
//Calculator receives the command and parses it
If sum(K={24,25,26,34,45,105,23
// The first chunk it processes is K, for this explanation, assume K=45
If sum(45={24,25,26,34,45,105,23
//The next chunk it processes is the equality
//Since we are applying the equality operator to a list, it applies to all items in the list
If sum({0,0,0,0,0,1,0,0
//Now we take the sum of the list
If 1
//If 1 returns true according to boolean logic
```

I also realize I probably didn't explain these lines very well:

```
If (K=23)(([B](Y,X)=2)+Jnot([B](Y,X):Then
----
If (K=105)not([B](Y,X)not([A](Y,X:1→[B](Y,X
```

I think it would be most helpful for you to try and understand them on your own, but they are a little complex to read without thinking about it. I don't know if you've seen the page on Piecewise Expressions, but that is the fundamental concept they are built from. If you have any questions on how those specifically get processed, let me know

CalcNerd 05 Aug 2020 12:46

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

I was wondering one thing… "If sum(K={24,25,26,34,45,105,23:Then". Do the "K" numbers have to be in a specific order or can they be changed around? Can it be like this? If sum(K={26,105,34,23,25,24,45

Thanks, it all works great and runs way faster. I may have to incorporate some of these new techniques in my future programming! Thank you a ton for all of your help. The Commented version was very helpful!

CalcNerd 03 Aug 2020 16:16

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

WOW! I have a lot of work to do! Thank you a ton for helping me with this project! I hope to expand on this program further! THANKS Again!

CalcNerd 03 Aug 2020 16:09

in discussion Programming & Design / TI-83/84/+/SE Programming » Tag Game Optimization

in discussion Programming & Design / TI-83/84/+/SE Programming » Tag Game Optimization

Sorry I typed in a few things wrong :( … Thank You for the code! I will work on improving it!

ERR_NAME_INVALID 03 Aug 2020 04:57

in discussion General Discussion / Open Topic » Project idea: gameboy assembly suite on TI-84+CE

in discussion General Discussion / Open Topic » Project idea: gameboy assembly suite on TI-84+CE

I'm making a gameboy assembly development environment for my TI-84+CE. I won't bore you with all of the stuff about the way data will be stored, other than that I need to read and write individual bytes at a time from large variable of some sort. Preferably such a variable would be of variable size from 0 bytes to more than 16KiB (upper limit preferably more than 22KiB, just in case). 16KiB is the size of gameboy ROM banks, but I will need more than this because of markers bloating the data.

The question is how or where do I store that much data? I have no idea and would really appreciate some ideas from you guys. Also, in the longer version I go into more detail about the way it all works, if you're interested in hearing what I intend to do with this project.

I've had the idea in my head for a while to write a gameboy assembly development suite for my '84 CE. I know this is an ambitious and just plain silly project, but I think it will be a lot of fun.

Anyways, how to store the code? Well, the program would just write the bytes for each instruction to a variable of some sort, and read and interpret the instruction opcodes on the fly, basically acting as a live disassembler/assembler. This would cut down the size of the project files, at the cost of giving the program a LOT more to do.

Things such as labels, section definitions and chunks of raw data (such as graphics data) could just be inserted into the data directly, as there's 11 unused instruction opcodes in the gbz80 instruction set that could just be interpreted as markers instead of as instructions.

And to export the project files? I could just upload them to my laptop and do whatever I want with them from there. I could easily write a custom disassembler in python to interpret the unused opcodes and produce a .asm file to be compiled with RGBDS or whatever. Or I could write a simple program to remove the extra markers, and do other things to make the ROM image execution ready.

There's just one problem: How the heck do you store that much mutable bulk data efficiently? I mean storing LOTS of individual bytes in a single variable. Preferably such a variable would be of variable size from 0 bytes to more than 16KiB (upper limit preferably more than 22KiB, just in case). 16KiB is the size of gameboy ROM banks, but I will need more than this because of markers bloating the data.

Using lists is not an option, and this post was too long for all of the details. To summarize: With cramming four bytes into each number in the list (which is the limit of the integer resolution) only 44% of the RAM taken up by the list is the actual bytes of data being stored, and lists have a limit of 999 items which means only about 4K per list can be stored. It's unworkable every way to sunday.

Summary: The calculator has more than enough space to handle at least four 16KiB+ banks of data at a time, and enough archive space to store a fairly large gameboy game's worth of ROM banks. But where/how the heck do you store it? I've got no idea, and ny help I get will be much appreciated.

kg583 03 Aug 2020 00:59

in discussion Forum 101 / Community Introductions » Hello, TI programming community!

in discussion Forum 101 / Community Introductions » Hello, TI programming community!

Welcome to TI|BD, ERR_NAME_INVALID.

This site is pretty quiet these days, but a plenty good place to learn and explore TI-BASIC nonetheless. Feel free to take a look at the Starter Kit or some of the other tutorial pages for whatever project you decide to pursue next. Also be sure to read the Rules and Wiki Conventions for information/tips on avoiding "n00b level mistakes" while making use of the forum and wiki.

As for assembly, you might find a more active community on Cemetech (if you're not already a member). At any rate, everyone there and here on TI|BD is happy to assist in any of your programmatic pursuits.

Happy coding,

kg583

The solution to a complex problem is often a simple answer.

Trenly 02 Aug 2020 23:34

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

I think you need some more checks for the mines, because I ran it on my calculator and it only generated 7 mines. I ran it a few times and it generated 7,11,12, and 10.

Try this code for validating your function:

```
DelVar [A]{8,16→dim([A]
[A]→[B]
For(I,1,A
randInt(2,7→Y
randInt(2,15→X
If [A](Y,X)=9
A+1→A
9→[A](Y,X
End
//Your function above this line
//Testing below
dim([A]→L₆
DelVar C
For(I,1,L₆(1)
For(J,1,L₆(2)
If [A](I,J)=9:C+1→C
End
End
Disp C
```

Other Optimizations:

I was bored so I made an "optimized" version of yours, which could probably be optimized further but I didn't want to put too much time into it:

(Updated Flag button to Del, Other than that arrows still move and enter clicks)

```
DelVar [A]{8,16→dim([A]
[A]→[B]
DelVar A
Repeat A=10
randInt(2,7→Y
randInt(2,15→X
If [A](Y,X)≠9:Then
9→[A](Y,X
A+1→A
End
End
ClrHome
1→X:10→J
For(I,1,12
Output(4,3,sub("MINE*SWEEPER",1,I
X+(X≠5→X
Output(5,6,sub("V 1.1",1,X
End
Repeat K=105
getKey→K
min(8,max(7,Y+(K=34)-(K=25→Y
Output(7,7,"PLAY
Output(8,7,"EXIT
If Y=8:Output(Y-1,6," "
If Y=7:Output(Y+1,6," "
Output(Y,6,">
End
For(I,1,38
Output(randInt(1,8),randInt(1,16),"*
End
ClrHome
If Y=8:Return
4→Y:8→X
Output(1,1," -MINE*SWEEPER- "
Output(8,5,"FLAGS:
Output(8,11,J
For(A,2,7
Output(A,1,"I
Output(A,16,"I
For(B,2,15
Output(A,B,"x
End
End
Output(Y,X,"+
Repeat K=45 or K=1
getKey→K
If sum(K={24,25,26,34,45,105,23:Then
If sum(K={24,25,26,34:Then
Output(Y,X," "
Y→A:X→B
max(2,min(15,X+(K=26)-(K=24→X
max(2,min(7,Y+(K=34)-(K=25→Y
Output(Y,X,"+
If [B](A,B)=2:Output(A,B,"/
If [B](A,B)=0:Output(A,B,"x
If [B](A,B)=1:Then
DelVar E
For(I,A-1,A+1
For(H,B-1,B+1
If [A](I,H)=9:E+1→E
End
End
Output(A,B,E
End
End
If (K=23)(([B](Y,X)=2)+Jnot([B](Y,X):Then
J-1+2([B](Y,X)=2→J
abs([B](Y,X)-2→[B](Y,X
Output(8,11," "
Output(8,11,J
End
If (K=105)not([B](Y,X))not([A](Y,X:1→[B](Y,X
If (K=105)[A](Y,X)=9:1→K
End
End
0→F
For(A,2,7
For(B,2,15
If [A](A,B)=9 and [B](A,B)=2:F+1→F
End
End
ClrHome
If K=1:Disp "YOU HIT A MINE!
Disp "YOU CLEARED
If F=10:Disp "ALL
Disp F,"OF THE MINES
"
```

Commented version:

ERR_NAME_INVALID 02 Aug 2020 18:13

in discussion Forum 101 / Community Introductions » Hello, TI programming community!

in discussion Forum 101 / Community Introductions » Hello, TI programming community!

Thanks! I'm glad to be here.

Cool. Now I know [a bit] more about this topic and might look into it sometime. =)

CalcNerd 02 Aug 2020 12:31

in discussion Forum 101 / Community Introductions » Hello, TI programming community!

in discussion Forum 101 / Community Introductions » Hello, TI programming community!

Welcome to the community!

Edit: I am probably the least qualified to welcome you, but I hope you enjoy this community!

ERR_NAME_INVALID 02 Aug 2020 03:06

in discussion Forum 101 / Community Introductions » Hello, TI programming community!

in discussion Forum 101 / Community Introductions » Hello, TI programming community!

Hi all! I'm pretty much brand new to TI programming in general. I have a Ti-84 Plus CE as well as a Ti-82 (ROM version 18.0 for those interested). And yes, my TI-84 PCE is running OS ver. 5.3.0, but my boot code is 5.3.6 so I had to go through the downgrade process.

I've messed around with Ti-basic a little bit, but I know nothing about optimization and other basic things. I however am NOT new to assembly programming. I learned the fundamentals of z80 assembly through learning how to write assembly for the gameboy, which uses a Sharp LR35902 core @ 4.19 MHz. This is a stripped down z80 (no IX or IY registers, or LDIR for that matter) with some extra instructions (such as the SWAP instruction which swaps the high and low nybble of the accumulator).

It seems nice here, and I hope to be a semi-active member of this community. In addition to that, I'm new to how forums work, so please don't blast me for dumb n00b level mistakes. Other than that, I'm excited to be part of the community and look forward to chatting with all of you!

CalcNerd 01 Aug 2020 23:55

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

in discussion Programming & Design / TI-83/84/+/SE Programming » MineSweeper Optimization

I think that my code has no memory leaks (fingers crossed). I am looking for help to make the code more efficent as well as cut down the byte numbers. Any advice is extremely helpful!

All of the code should be correct. I ran it on another calculator and pasted it here. Let me know if its not.

I probably used some weird methods. Sorry about that. :)

Controls:

Move: Arrow Keys

Dig: Enter

Graph :Update the screen (not character only dug spots,flags,etc.)

Trace :Place Flag

Zoom :Remove Existing Flag

Clear : When all flags are placed hit clear to check if you won

Edit: I put in two more lines to ensure that there will be 10 mines in different locations.

```
DelVar [A]{8,16→dim([A]
[A]→[B]
For(I,1,A
randInt(2,7→Y
randInt(2,15→X
//I changed this for the mines as mentioned above and the For(I,1,A the last syntax was changed to A
If [A](Y,X)=9
A+1→A
9→[A](Y,X
End
1→X:10→J
ClrHome
For(I,1,12
Output(4,3,sub("MINE*SWEEPER",1,I
X+(X≠5→X
Output(5,6,sub("V 1.0",1,X
End
7→Y:6→X
Repeat K=105
getKey→K
Output(7,7,"PLAY
Output(8,7,"EXIT
Y+(K=34 and Y≠8)-(K=25 and Y≠7→Y
If Y=8
Output(Y-1,X," "
If Y=7
Output(Y+1,X," "
Output(Y,X,">
End
For(I,1,38
Output(randInt(1,8),randInt(1,16),"*
End
ClrHome
If Y=8
Return
4→Y:8→X
Output(1,1," -MINE*SWEEPER- "
Output(8,5,"FLAGS:
For(I,2,7
Output(I,1,sub("IIIIII",I-1,1
Output(I,16,sub("IIIIII",I-1,1
End
Repeat J=0 and K=45 or K=105 and [A](Y,X)=9
getKey→K
Output(8,11,J
If J≠10
Output(8,12," "
If not([A](Y,X)=2
Output(Y,X," "
X+(K=26 and X<15)-(K=24 and X>2→X
Y+(K=34 and Y<7)-(K=25 and Y>2→Y
Output(Y,X,"+
If K=14
Then
2→[B](Y,X
J-1→J
End
If K=13 and [B](Y,X)=2
Then
0→[B](Y,X
J+1→J
End
If K=105 and [A](Y,X)=0
1→[B](Y,X
If K=15
Then
2→A:1→B
For(I,1,84
B+1→B
If B>15
Then
A+1→A
2→B
End
If [B](A,B)=2
Output(A,B,"/
If [B](A,B)=0
Output(A,B,"x
If [B](A,B)=1
Then
If [A](A-1,B)=9
E+1→E
If [A](A+1,B)=9
E+1→E
If [A](A,B+1)=9
E+1→E
If [A](A,B-1)=9
E+1→E
If [A](A-1,B-1)=9
E+1→E
If [A](A+1,B-1)=9
E+1→E
If [A](A-1,B+1)=9
E+1→E
If [A](A+1,B+1)=9
E+1→E
If [B](A,B)=1
Output(A,B,E
0→E
End
End
End
End
0→F
2→A:1→B
For(I,1,84
B+1→B
If B>15
Then
A+1→A
2→B
End
If [A](A,B)=9 and [B](A,B)=2
F+1→F
End
If F=10
Then
ClrHome
Output(1,1,"YOU CLEARED ALL OF THE MINES!
Pause
Return:"
End
ClrHome
If F<10
Then
Disp "YOU CLEARED
Disp F
Disp "OF THE MINES
End
```