Author Topic: Appvar data manipulation  (Read 10872 times)

0 Members and 1 Guest are viewing this topic.

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
Appvar data manipulation
« on: April 28, 2011, 02:49:56 am »
The code below is eventually going to be put in the Tio level editor.
The idea is to either insert or remove a level from the pack.
Str0T is temp string, something like "appvTEMPLVL"
Str0L is the real level set.
r6 is the pointer to start off the level var.  getcalc(thing)→r6 then →P.
P is manipulated to change the level that's pointed to within the set.
Q is simply {r6-2}^r stored to a var
One level is 384 bytes large, one "level slot"
After INSERT
Inserts a level where the pointer is.  One slot.
What  it's  *supposed* to do is copy all the data from the current pointer  one slot forward, making the level larger and leaving a gap where the new level can be started.
After DELETE
Removes the level pointed to.
Pulls back the levels after the currently-pointed-to level, shrinking the pack and overwriting the current level.
The 31337 lets the game know, when it's reading through the level appvar, where the appvar ends.
So, the code.

Main editor program to an extent
Code: [Select]
PROGRAM:STIO10E
:.program start
:.header, sprites, strings, main menu, level select
:.more stuff
:Lbl E
:.Editor start
:.load level, start main loop
:.main loop starts
:.cursor movement code...
:If getKey(10):3→r1:Goto LVL:End
:If getKey(11):4→r1:Goto LVL:End
:If getKey(12):1→r1:Goto LVL:End
:If getKey(13):2→r1:Goto LVL:End
:.rest of main loop
:.main loop ends
:.subroutines
:Lbl LVL
:prgmLEVEL
:Goto E
Sub-program
Code: [Select]
PROGRAM:LEVEL
:..
:{r6-2}^r→Q
:.^r is same as the result of [sup]r[/sup]
:!If r1-1
:.Q-1→Q
:.INSERT
:GetCalc(Str0T,Q)→B
:GetCalc(Str0L)→C
:copy(C,B,Q)
:GetCalc(Str0L,Q+384)→C
:copy(B,C,Q)
:31337→{Q+384→Q+C+1}^r
:End
:!If r1-2
:.DELETE
:If Q+385
:Q-384→Q
:GetCalc(Str0T,Q)→B
:GetCalc(Str0L)→C
:copy(C,B,Q)
:GetCalc(Str0L,Q)→C
:copy(B,C,Q)
:31337→{Q+r6}^r
:End
:End
:.manual switch
:!If r1-3
:.previous
:If P-r6
:P-384→P
:End
:!If r1-4
:If {P+383}^r-31337
:P+384→P
:End
:.Return

I've tried this code, and it led to a pretty epic RAM clear, even caused the BLOD somehow :P
On another try it made a gigantic overflow variable which on recall caused another crazy RAM clear.
Clearly, I'm going to need some help getting this to work properly...
1) is it plausible?
2) what's wrong with it?  I've been coding for less than a year and make some pretty dumb mistakes sometimes, and I'm guessing this might be another one...
3) can it be fixed, or would it need to be completely re-written?

EDIT: this code, and the text almost verbatim, is in a kompispad (read:etherpad) at http://kompisen.se/tio and the "Tio Dev" link in my sig goes there as well.
« Last Edit: April 28, 2011, 07:46:10 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Appvar data manipulation--help needed
« Reply #1 on: April 28, 2011, 03:06:53 am »
So basically what you want is
first creating an appvar
then add and delete levels?
I recommend that you create an appvar for lets say 8 levels. then let the user choose the level to edit and save it in the appvar. I think the reason for the RAM clear is that you have overflown the appvar.
You can add/del levels by using a short list at the start of the appv, for example if level 1-3 are used would the data at the start be 1,1,1,0,0,0,0,0.
I hope this will help you!
I'm not a nerd but I pretend:

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: Appvar data manipulation--help needed
« Reply #2 on: April 28, 2011, 03:36:48 am »
Made a more graphic representation of what I'm going for.
Vy'o'us pleorsdti thl'e gjaemue

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Appvar data manipulation--help needed
« Reply #3 on: April 28, 2011, 03:37:43 am »
The problem is most likely that you overflow the appvar.
I'll take a look at this later, better run to class now ;)
« Last Edit: April 28, 2011, 03:38:08 am by aeTIos »
I'm not a nerd but I pretend:

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Appvar data manipulation--help needed
« Reply #4 on: April 28, 2011, 04:44:40 am »
For this you'll need to use insertmem and delmem, so asm.

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: Appvar data manipulation--help needed
« Reply #5 on: April 28, 2011, 05:26:21 am »
...or use MemKit.  What you're describing is exactly what its there for.  It gives you the ability to insert any number of bytes into an appvar at any location, or remove bytes from a location.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Appvar data manipulation--help needed
« Reply #6 on: April 28, 2011, 05:49:25 am »
O.O didn't know that, thanks !

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Appvar data manipulation--help needed
« Reply #7 on: April 28, 2011, 06:36:25 am »
Cool!
I'm not a nerd but I pretend:

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: Appvar data manipulation--help needed
« Reply #8 on: April 28, 2011, 02:37:38 pm »
Memkit!  Completely forgot that...
:banghead:
Vy'o'us pleorsdti thl'e gjaemue

Offline yrinfish

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 138
  • Rating: +8/-0
  • Zark, I'm not dead
    • View Profile
    • yrinthings
Re: Appvar data manipulation--help needed
« Reply #9 on: April 28, 2011, 04:15:11 pm »
But how does it (memkit) exactly work? Shifting the rest of the bytes? Or does it buy a new RAM-chip?
I need help with Random (x86 Happy), pm me if you want to help :D
LOOK IN MY SPOILER, MY SIG IS UPDATED (almost) EVERY DAY
Spoiler For MiniTale:
No mini competition please, teamwork is better :D
I suggest we do not use "MiniCraft" as the name:
Notch has asked us to not do that.
It will get changed to "MiniTale"
@Hayleia, you don't _have to_ organize :P
THIS POST IS IN MY SIG TOO

Details
Language: Axe
Platform: TI 83+

Things we'll need to do/make
Draw the sprites saintrunner is working on this
A save file format.
A level generator.
A Tilemapper.
Some sort of AI.
Crafting system.

People on it (AFAIK)
annoyingcalc
saintrunner
Hayleia (your avatar is really cool btw)
epic7
Blue Raven
yrinfish

Useful info
For those who are going to work on this
General Program Structure
Spoiler For Spoiler:

:.Sprite Data
:.Other Data
:
:.Main menu
:.Option Start Game->init
:.Option How To Play->help
:.Option About->crdt
:
:.BEGIN init
:.Save file is present?
:.yes->strt
:.no->lgen
:.END init
:
:.BEGIN lgen
:.Make appvar appvMCSAVE
:.create 7 levels
:.edit for sky, mines, deep mines, nether
:.END lgen
:
:.BEGIN strt

~~~~ working on this ~~~~

Tiles
Spoiler For Spoiler:
Wheat
Water
Tree
Stone
Stairs
Sapling
Sand
Rock
Ore
Lava
InfiniteFall
Hole
HardRock
Grass
Flower
Farm
Dirt
Cloud
CloudCactus
Cactus

Biomes
Spoiler For Spoiler:
--Sky
Cloud
--Surface
Forest
Meadow
Plains
Cliffs
Mountain
Desert
Ocean
--Underground
Mines
Deep Mines
Nether

Items
Spoiler For Spoiler:
--Tools
Pick
Axe
Hoe
Shovel
--Weapon
Sword
--Utilities
Pow Glove
Workbench
Furnace
Lantern
Anvil
Oven
Chest
--Resources
Apple
Bread
Cloth
Slime
Wood
Seeds
Wheat
Acorn
Cactus
Flower
Cloud
Dirt
Stone
Sand
Coal
Iron Ore
Gold Ore
Gem
Glass
Iron
Gold
Spoiler For More...:
Spoiler For About me:

No, I didn't lie!!


quotes:HERE

And even more:


[07:53:14] <+Frey> Y'know, when people descend from my heavens , they're never Chuck Norris
[07:53:55] <+Frey> I usually get another catgirl or an angel pops down for a visit
[07:54:06] <+Frey> Some angels are really nice
[07:54:33] <+Frey> Some are into the whole "scare the locals" bit
[07:54:54] <+Frey> And some just absent minded
[07:55:38] * +david_ has nothing to do
[07:55:40] <+Frey> It's the absentminded ones you gotta look out for, because the'yre the ones that forget they're 40ft tall
[07:56:04] <+Frey> They're also the ones that forget about social taboos, like nudity
[07:56:28] <+Frey> Have you ever tryed to explain to an angel...anything?
[07:56:45] <+Frey> They don't listenunless they want to
[07:57:16] <+Frey> And don't learn unless they think they don't know
[07:57:51] <+Frey> Except for the nice ones, they're nice
[07:59:27] <+OmnomIRC> (O)<yrinfish> lol
[07:59:32] <+Frey> And they're all so pretty!
[07:59:38] <+Frey> It's ridiculous
[07:59:44] <+OmnomIRC> (O)<yrinfish> I hate PUSHES, THEY HAUNT ME
[08:00:06] <+Frey> Want an angel to come over and exorcise them?
[08:00:36] <+OmnomIRC> (O)<yrinfish> or, more specific: the fact that sometimes, happy outputs: pushes != pops
[08:00:47] <+OmnomIRC> (O)<yrinfish> I know why
[08:01:01] <+OmnomIRC> (O)<yrinfish> and I can solve it by adding a lookahead
[08:01:10] <+OmnomIRC> (O)<yrinfish> But I don't want to
[08:01:24] <+OmnomIRC> (O)<yrinfish> but continue your story
[08:01:35] <+OmnomIRC> (O)<yrinfish> lol
[08:03:13] <+Frey> Ok, so one day, I was walking to the school bus, and, long story short, got my life saved by an angel
[08:03:27] <+Frey> This one was a scary one
[08:03:42] <+Frey> Same height/age as me
[08:04:14] <+Frey> OMG She was the scariest person I had ever met
[08:04:28] <+Frey> She made the entire football team pee their pants
[08:04:43] <+Frey> I was so glad she was on my side
[08:05:04] <+Frey> Right up until she tryed to enter the bathroom with me
[08:05:37] <+OmnomIRC> (O)<yrinfish> lool
[08:05:45] <+Frey> After a muchness of arguing, I finally got through to her
[08:05:56] <+Patrick-D> is this a rap song?
[08:06:06] <+OmnomIRC> (O)<aeTIos> idk
[08:06:09] <+Frey> She tap danced outside my stall the entire time, though
[08:10:04] <+Frey> She was in all my classes too, which was weird, especially as they were all advanced courses and she joined in the middle of the semester
[08:10:28] <+Frey> Even the teachers were scared of her
[08:10:45] <+Frey> Note that she was gorgeous
[08:12:09] <+Frey> So, this angel and I, we managed to stop the apocalypse
[08:12:48] <+Frey> And she kissed me before going back,
[08:13:08] <+Frey> To heaven, but as it turns out that kiss sealed her to Earth
[08:13:47] <+Frey> We still don't know what to do


lol:

[11:30:53] <DThought> <OmnomIRC> (O)<yrinfish> 2 guests are looking at my topic
[11:30:53] <DThought> <OmnomIRC> (O)<yrinfish> I wonder who they are
[11:30:53] <DThought> <OmnomIRC> (O)<yrinfish> where they live
[11:30:53] <DThought> <OmnomIRC> (O)<yrinfish> how old they are
[11:30:55] <DThought> <OmnomIRC> (O)<yrinfish> What kind of jokes they make
[11:30:57] <DThought> <OmnomIRC> (O)<yrinfish> but it surprises me that theyre looking at my topic
[11:31:01] * DThought smacks yrinfish for stalking
[11:31:08] <yrinfish> lool
[11:31:14] <DThought> Whoa, why'd it include all the newlines?
[11:31:23] * calc84maniac  smacks DThought for talking
[11:31:28] * calc84maniac  runs

Crisps:

<OmnomIRC> (O)* Keoni29  Eating crisps
<OmnomIRC> (O)* yrinfish  asks keoni some
<OmnomIRC> (O)<Keoni29> 7$ shipping please
<OmnomIRC> (O)* yrinfish  gives
<OmnomIRC> (O)<Keoni29> It will arrive in 3 days
<OmnomIRC> (O)<yrinfish> Thank you
<OmnomIRC> (O)* Keoni29  Wonders if he wants some dip
<OmnomIRC> (O)<yrinfish> chili please
<OmnomIRC> (O)<Qwerty.55> Adobe, last time I updated one of your products, the changes broke half of the documents using it.
<OmnomIRC> (O)<Keoni29> :(
<OmnomIRC> (O)<Qwerty.55> Why the hell would I update anything else from you?
<OmnomIRC> (O)* yrinfish  kicks adobe
<OmnomIRC> (O)* yrinfish  runs
<OmnomIRC> (O)* Qwerty.55  runs with him
<OmnomIRC> (O)<Keoni29> I have guacamole :S
<OmnomIRC> (O)<Keoni29> I have guacamole :S
<OmnomIRC> (O)* yrinfish  likes that too
<OmnomIRC> (O)* Keoni29  yay
<OmnomIRC> (O)* yrinfish
<OmnomIRC> (O)<Keoni29> http://www.tinyurl.com/guacamole.jar
<OmnomIRC> (O)<Keoni29> :3
<OmnomIRC> (O)<yrinfish> 404
<OmnomIRC> (O)<yrinfish> no foooooooooooooooooooooooouwaaaaaaaaaaaaaaaaahnd
<OmnomIRC> (O)<Keoni29> <3 no shit
<OmnomIRC> (O)<Keoni29> You cant download jars of guacamole
<OmnomIRC> (O)<Keoni29> I have an idea!
<OmnomIRC> (O)<yrinfish> loool
<yrinfish> that came too late ;)
<OmnomIRC> (O)<Qwerty.55> Actually, I just realized why Adobe's update breaks everything.
<yrinfish> tell me
<yrinfish> again too late
<OmnomIRC> (O)<Keoni29> Buy yourself some :3
<yrinfish> that was to keoni
<yrinfish> lOLoL
<yrinfish> :D
<OmnomIRC> (O)<Qwerty.55> It's a security update and if you can't run anything, you obviously can't get infected by anything in those documents.
<OmnomIRC> (O)<Keoni29> Then I pay one dip
<OmnomIRC> (O)<Keoni29> Do you have paypal?
<OmnomIRC> (O)<Keoni29> :S
<OmnomIRC> (O)<yrinfish> nope
<OmnomIRC> (O)<yrinfish> lol
<OmnomIRC> (O)<yrinfish> hm, I could get some crisps
<OmnomIRC> (O)<yrinfish> it is too late to do that here
<OmnomIRC> (O)<yrinfish> main europe
* jkag ([email protected]) has joined #omnimaga
* Netbot45 gives voice to jkag
<OmnomIRC> (O)<yrinfish> MUSIC YAY
<OmnomIRC> (O)<Keoni29> Well the shops are closed here too
<OmnomIRC> (O)<Keoni29> 21:45
<OmnomIRC> (O)<yrinfish> where?
<OmnomIRC> (O)<Keoni29> Gwt+0
<OmnomIRC> (O)<Keoni29> The netherlands
<OmnomIRC> (O)<yrinfish> huh? loool
<OmnomIRC> (O)<yrinfish> hallo keoni, hoe gaat het? continue in english please
<OmnomIRC> (O)<Keoni29> :S
<OmnomIRC> (O)<yrinfish> really stupid dutch sentence^

Languages:
1308401677 <yrinfish> I'm dutch
1308401679 <yrinfish> lol
1308401687 <p2> Oh.
1308401702 <yrinfish> So I need to learn german
1308401705 <yrinfish> and french
1308401712 <yrinfish> and English
1308401717 <yrinfish> and Dutch
1308401724 <yrinfish> and Greek
1308401728 <yrinfish> and Latin
1308401739 <p2> I must learn french and English.
1308401739 <yrinfish> and Spanish
1308401749 <Spyro543> Y=sin(x+yrinfish)*>9000
NOTE: these are all the languages I have chosen to learn!
Spoiler For Info:

Spoiler For Projects:
Happy    [.---------] A C-like programming language for the z80 in js. REWRITING THE WHOLE THING, GOOD IDEAS NEEDED
DionJump [======----] Paused, but there is an update
Corona   [----------] Not enough time... If you need inspiration?
LGETC    [======----] getchar() LUT, useful and not too big. Waits for keyboard input and returns ASCII char

Spoiler For yrinthings tools:
stringLength Get the length in pixels of a small-font string.
safeText Html-ify a piece of text.

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: Appvar data manipulation--help needed
« Reply #10 on: April 28, 2011, 06:57:32 pm »
It's an axiom (external routines which can be called), which by the way I failed on figuring out how to use :P
Can't find the tokens anywhere...
* Darl181 starts looking for a tutorial
Or maybe one can tell how to use it precisely?  I got the #Axiom line down but can't fine the tokens (ie New( Delete( )

EDIT: just re-read the memkit readme, a lot clearer after trying fsr :P
« Last Edit: April 28, 2011, 07:06:23 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Appvar data manipulation--help needed
« Reply #11 on: April 28, 2011, 07:40:22 pm »
But how does it (memkit) exactly work? Shifting the rest of the bytes? Or does it buy a new RAM-chip?

It shifts bytes around. There are two bcalls (_InsertMem and _DelMem) for that very purpose, automatically shifting the appropriate bytes and updating all var pointers. MemKit is basically an Axe front-end for that, with some other useful features.




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: Appvar data manipulation
« Reply #12 on: April 30, 2011, 02:39:19 am »
Can someone clarify what the offset argument in New( and Delete( is supposed to be?  Is it the byte in ram at which it's located, or the bytes from the start of the var?
I tried it as # of bytes from the start of the var and it made a ~3kb y-var :P
TIA
« Last Edit: April 30, 2011, 02:41:11 am by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

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: Appvar data manipulation
« Reply #13 on: April 30, 2011, 01:54:24 pm »
Bump.
I tried it again last night, this time the y-var was 4kb :P
I just now went through the readme again.
Quote
New(PTR,OFS,SIZ)    Arguments: PTR = Pointer to start of program/appvar (from getcalc).
                               OFS = Offset in program to add memory
                               SIZ = Size of memory to insert
                    Returns: 0 if it failed, non-zero if it succeeded.
                    Description: Attempts to inflate the size of a program/appvar

Delete(PTR,OFS,SIZ) Arguments: PTR = Pointer to start of program/appvar (from getcalc).
                               OFS = Offset in program to start deleting memory
                               SIZ = Size of memory to delete
                    Returns: 0 if it failed, non-zero if it succeeded.
                    Description: Attempts to shrink the size of a program/appvar
still not very clear, even in retrospect...

EDIT: is the two-byte r modifier needed?

EDIT2: attached problematic stuffs.  uses memkit, and LEVEL is a sub-program
btw made with axe 0.5.0
« Last Edit: April 30, 2011, 02:55:08 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue