Author Topic: Using AppVars, more help!  (Read 8228 times)

0 Members and 1 Guest are viewing this topic.

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Using AppVars, more help!
« on: June 26, 2011, 03:49:46 pm »
Okay, I read FinaleTI's external vars tutorial, but I still have a couple of questions.

1) So from what I understand, accessing the data in my appvars, I need to know EXACTLY where everything is, knowing exactly what byte it is at. Correct?
2) How would I go about storing PICs and tilemaps in AppVars and then accessing that data?

If you need more info, ask. I will probly add more questions to this as I go along programming this game.

edit:
3) How do I get my Pic out of the appv and store it to Pic1? I have tried a variety of methods but none seem to work.
« Last Edit: June 27, 2011, 01:30:53 am by jkag »

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Using AppVars, more help!
« Reply #1 on: June 26, 2011, 03:53:11 pm »
1) Yes indeedly
2) You need to know how many bytes each PIC and tilemap takes up. For example, if I had a 108 byte tilemap (For Tag! ^^) then I would do something like

Accessing:
3->L //Store offset into a var
getCalc("appvTEST")->V //Load appvar into a pointer
Copy(L*108+V,L1,108) //Copy the 4th tilemap (3+1, starts at 0), which is 108 bytes, into L1 space of free ram.

Do the same with PICS. Note that with appvars it's a bit more difficult because you need to know explicitly how large each item is.
« Last Edit: June 26, 2011, 03:53:45 pm by leafiness0 »
In-progress: Graviter (...)

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Using AppVars, more help!
« Reply #2 on: June 26, 2011, 03:56:01 pm »
So, how big is say an 8x8 sprite in hex? Just so I know.

This might make it a little hard to make the engine easy to use with a custom APPVAR system... There would have to be extremely strict specifications on how to build the appvars.

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Using AppVars, more help!
« Reply #3 on: June 26, 2011, 03:59:06 pm »
an 8*8 is 8 bytes, which means a 16 character alpha-numeric code per sprite

EDIT: oh, and instead of having an exact size for each object you could always just use a specific pattern of values to act as a header, indicating that one is ending and another is beginning, and then just number your objects to find the offset to it in your data. or, as another option, you could have a list that's a set size at the beginning of your appvar which holds, in a set number of bytes (say 2-4) indicates the size of your object and the offset to where it begins. that would mean that, in order to find the 3rd tileset (or whatever it is you happen to be storing) you could just skip to the 3rd entry in the table, find it's position and size, and work from there.
« Last Edit: June 26, 2011, 04:03:17 pm by shmibs »

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Using AppVars, more help!
« Reply #4 on: June 26, 2011, 04:00:03 pm »
Thanks!

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Using AppVars, more help!
« Reply #5 on: June 27, 2011, 01:31:31 am »
First post updated. I'm not sure what exactly doub post rule is... but meh. my last post was one worded lol.

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Using AppVars, more help!
« Reply #6 on: June 29, 2011, 05:33:17 pm »
Bumping since it has been a couple of days, and I need help on one more thing, the menu. The loading is strange and I know the !Str1 etc is not proper syntax I was playing around trying to iron bugs out and I misinterpreted what someone said
Bugs:
Calculator crashes almost instantly
Chapters that are not existing on the calculator are appearing
Chapters are overlapping and pushing up to the top of the screen, instead of proper space

Code: [Select]
..MENU

2→C

If GetCalc("appvBLUTCH1")
"Chap 1"→Str1
C+1→C
End
If GetCalc("appvBLUTCH2")
"Chap 2"→Str2
C+1→C
End
If GetCalc("appvBLUTCH3")
"Chap 3"→Str3
C+1→C
End

C→[theta]

Repeat getKey(15)
 ClrDraw
 Fix 1:Fix 5
 Text(1,,"blut")
 Text(8,C*10,"Quit")
 Text(8,(C-1)*10,"Help")
 C-1→C
 If Str₃ and !Str₂ and !Str₃
  Text(8,(C-1)*10,Str3)
  C-1→C
 End
 If Str₂ and !Str₁ and !Str₃
  Text(8,(C-1)*10,Str2)
  C-1→C
 End
 If Str₁ and !Str₁ and !Str₂
  Text(8,(C-1)*10,Str1)
  C-1→C
 End
 DispGraph
 End
 
 .FULL MENU, STILL NEED KEYPRESSES ETC LOL

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Using AppVars, more help!
« Reply #7 on: June 29, 2011, 06:59:33 pm »
Strings are static pointers meaning that they are always constant and always defined.  Putting them in If statements doesn't do anything, it will behave as if you had put them in the beginning of your file (which you should always do by the way).  Also you might want to consider copying the file names in L1 so you can easily edit the ending number.  For instance:

Code: [Select]
:.Input: Arg1 = File number to look up
:Lbl GET
:Copy("appvBLUTCH1",L1,9) .Copy the name to L1
:r1+'0'->{L1+7} .Overwrite the last character
:Return GetCalc(L1) .Find the appvar

Then all you have to do to look up files is sub(GET,N) to get the pointer to the Nth file.
« Last Edit: June 29, 2011, 07:01:40 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Using AppVars, more help!
« Reply #8 on: June 29, 2011, 07:20:35 pm »
Okay, so then I'd check for drawing almost the same way correct? Or just using that instead?

like
Code: [Select]
If sub(GET,1)
.draw this option
end
if sub(GET,2)
.draw this option
end
.etc
correct?

or for a more complete version:
Code: [Select]
..MENU

2→C

If sub(GET,1)
 C+1→C
End
If sub(GET,2)
 C+1→C
End
If sub(GET,3)
 C+1→C
End

C→[theta]

Repeat getKey(15)
 ClrDraw
 Fix 1:Fix 5
 Text(1,,"blut")
 Text(8,C*10,"Quit")
 Text(8,(C-1)*10,"Help")
 C-1→C
 If sub(GET,3)
  Text(8,(C-1)*10,"Chap 3")
  C-1→C
 End
 If sub(GET,2)
  Text(8,(C-1)*10,"Chap 2")
  C-1→C
 End
 If sub(GET,1)
  Text(8,(C-1)*10,"Chap 1")
  C-1→C
 End
 DispGraph
 End
 
.Input: Arg1 = File number to look up
Lbl GET
Copy("appvBLUTCH1",L1,9) .Copy the name to L1
r1+'0'->{L1+7} .Overwrite the last character
Return GetCalc(L1) .Find the appvar
 
 .FULL MENU, STILL NEED KEYPRESSES ETC LOL

And I'm not sure if its my calc or not, this ram clears the thing.
« Last Edit: June 29, 2011, 07:40:27 pm by jkag »

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Using AppVars, more help!
« Reply #9 on: June 29, 2011, 08:29:26 pm »
You can use L# tokens as var names?
(you can type a theta with alt+233 Θ btw ;) )

Anyway idk but that might be causing the RAM clear

You can modify a string just like you're modifying L1.  I got that to work in Tio anyway..

EDIT: what might be causing the crash is that strings are zero-terminated (there has to be [00] at the end) and without that, whatever random junk is after the intended stuff at L1 is counted as part of the string until it reaches [00]--it probably tried to make a var with a >8-byte name...I'd just use a string, much safer :)

EDIT2: ok so the 0 is in there...idk :P

EDIT3: it's not in there unless r1=0.  you might want to put it in there after that ;)

EDIT4: the "" make a string, which should do the stuff on its own. oops :P
« Last Edit: June 29, 2011, 10:51:19 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Using AppVars, more help!
« Reply #10 on: June 29, 2011, 10:48:02 pm »
Quote
EDIT3: it's not in there unless r1=0.  you might want to put it in there after that Wink

what do you mean by this exactly?

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Using AppVars, more help!
« Reply #11 on: June 29, 2011, 10:49:40 pm »
Nvm that, it was cleared up in IRC that the quotes denote a string.

I was talking about r1+'0'->{L1+7} anyway

edited.
« Last Edit: June 29, 2011, 10:51:33 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Using AppVars, more help!
« Reply #12 on: June 29, 2011, 10:50:54 pm »
Yeah. I'm having trouble figuring out why my calculator crashes from this code... The menu isn't too important as of now, but it will have to be soon.

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Using AppVars, more help!
« Reply #13 on: June 29, 2011, 10:52:37 pm »
Have you tried simply using a string (as in storing to Str#)?  That might have to do with it...and as said before you can edit strings.

EDIT
Copy looks for a pointer.
Copy("appvBLUTCH1",L1,9)
"appvBLUTCH1" isn't exactly a pointer, it's data methinks

Try "appvBLUTCH1"→L1 ?
« Last Edit: June 29, 2011, 11:05:24 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: Using AppVars, more help!
« Reply #14 on: June 29, 2011, 11:03:16 pm »
If you look up, the code I am using (and I think you are referring to) is the code Quigibo gave me. And "appvBLUTCH1" is an appv, which copy uses I believe.