Author Topic: GDB's  (Read 8966 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
GDB's
« on: September 26, 2013, 01:46:19 am »
Ok so my code is probably very bad because even though Ive been doing this for a while, I do know much. Please correct me if im wrong or doing this wrong. Thanks! :)


Right now Im handling the X and Y values of a couple sprites in a GDB (they hold data like an array right?)
I then retrieve this data and edit it store it then later retrieve it and draw a sprite with it.
I have absolutely no problems when drawing one sprite, but when drawing 2 sprites with different X and Y data one of them will edit the first two digits of the sprite's hex code. Like when I move it right the hex code counts up by one and changes the sprite to match that.

Is this supposed to happen?
« Last Edit: September 26, 2013, 01:55:47 am by XiiR3CR34T10N »

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: GDB's
« Reply #1 on: September 26, 2013, 02:21:39 am »
Can you provide the code in question?


Also, it makes me cringe a bit inside when people refer to arbitrary data in Axe as "GDB's". The GDBX tokens are just a particular set of many equally allowable symbols in named pointers to any kind of data! You can call a pointer to any type of data whatever you want, whether it be GDB1, Str1XY, Pic789, °Stuff12345, or whatever.

Note: this isn't a personal thing, I'd just be happy to see a misleading and unfortunately common misconception due to archaic Axe syntax be made less common. (maybe even eradicated eventually?)
« Last Edit: September 26, 2013, 02:27:23 am by Runer112 »

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: GDB's
« Reply #2 on: September 26, 2013, 12:15:57 pm »
Oh ok, sorry abut that.
Here it's probably not perfect but It should do what I want to do right? (Unless I did something wrong.)

Code: [Select]
.test
1->X
1->Y

Fix 5

[01]->GDB1
[01]->GDB2

1->{GDB1}
1->{GDB2}
5->{GDB1+1}
1->{GDB2+1}

Repeat getKey(15)

If getKey(1)
Y+1->Y
End

If getKey(2)
X-1->X
End

If getKey(3)
X+1->X
End

If getKey(4)
Y-1->Y
End

X->{GDB1}
Y->{GDB2}
Y->{GDB1+1}
X->{GDB2+1}

ClrDraw

{GDB1}->A
{GDB2}->B
Pt-On(A/2,B/2,[FFFFFFFFFFFFFFFF])

{GDB1+1}->A
{GDB2+1}->B
Pt-On(A/2,B/2,[FFFFFFFFFFFFFFFF])
DispGraph
End

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: GDB's
« Reply #3 on: September 26, 2013, 12:21:17 pm »
Erm, I can see problems in your code. I don't know if this is what causes your problem, but you are writing in GDB1+1 which is GDB2, and you are writing in GDB2+1 which is... undefined, so it is a random place in your program or even outside of your program.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: GDB's
« Reply #4 on: September 26, 2013, 12:23:58 pm »
I see the problem in the code:

GDBs are pointers

Pointers must be the same size as the number of bytes that you want to modify/be in it because if you overextend the writing, you write to the next bytes, or in this case, the first byte of GDB2.

The fix:

[0000]->GDB1
[0000]->GDB2


EDIT: :ninja: 'd
« Last Edit: September 26, 2013, 12:24:31 pm by pimathbrainiac »
I am Bach.

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: GDB's
« Reply #5 on: September 26, 2013, 12:24:40 pm »
OH I get it! I've been experimenting with them to try and figure out how they work. Thought I had it. <_<

Edit OH!!
EVEN more understanding! Thanks guys!
« Last Edit: September 26, 2013, 12:25:14 pm by XiiR3CR34T10N »

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: GDB's
« Reply #6 on: September 26, 2013, 12:37:23 pm »
Using custom names for this might make your life easier, since your data is really just 1-byte variables and there's an easy way to access 1-byte variables: Nameʳ. Here's how it would look converted to use them, also with some other minor optimizations:

Code: [Select]
.TEST
1→X→Y

Fix 5

L₄→°X1+1→°Y1+1→°X2+1→°Y2
.Initialization of vars above not necessary, will be set in first loop iteration

ClrDraw

While 1

If getKey(1)
Y+1→Y
End

If getKey(2)
X-1→X
End

If getKey(3)
X+1→X
End

If getKey(4)
Y-1→Y
End

X→X1ʳ→Y2ʳ
Y→Y1ʳ→X2ʳ

Pt-On(X1ʳ/2,Y1ʳ/2,[FFFFFFFFFFFFFFFF])
Pt-On(X2ʳ/2,Y2ʳ/2,[FFFFFFFFFFFFFFFF])
DispGraphClrDraw  .for speeds!

EndIf getKey(15)
« Last Edit: September 26, 2013, 12:37:45 pm by Runer112 »

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: GDB's
« Reply #7 on: October 24, 2013, 06:35:44 pm »
Is there anyway to change the size of the array after you make it like.
Code: [Select]
[01020405]->GDB1
[02030302]
[04050302]


Is there any way to change the size of this after I make it?

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: GDB's
« Reply #8 on: October 24, 2013, 07:31:16 pm »
Also, it makes me cringe a bit inside when people refer to arbitrary data in Axe as "GDB's". The GDBX tokens are just a particular set of many equally allowable symbols in named pointers to any kind of data! You can call a pointer to any type of data whatever you want, whether it be GDB1, Str1XY, Pic789, °Stuff12345, or whatever.

i came here expecting a discussion about graphical debuggers for axe :P (although, that might not be the worst of ideas, and it wouldn't be all that hard to make as an axiom either...)


EDIT:
Is there anyway to change the size of the array after you make it like.
Code: [Select]
[01020405]->GDB1
[02030302]
[04050302]


Is there any way to change the size of this after I make it?

no, pointers set at compile time are static.
« Last Edit: October 24, 2013, 07:32:13 pm by shmibs »

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: GDB's
« Reply #9 on: October 24, 2013, 09:12:53 pm »
Um... That didn't exactly answer what I was wondering. Yes you can change it or No you can't change it?

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: GDB's
« Reply #10 on: October 25, 2013, 12:43:38 am »
Well, "size of an array" doesn't mean anything in Axe.

When you define [060203]->GDB1, what you are doing is
[06]->GDB1
[02]->GDB1+1
[03]->GDB1+2
And since you don't define anything at GDB1+3, the program sets what it wants there. That doesn't mean you can't read what's in GDB1+3, there is a value there, it will just be a bit unpredictable. That also means that if you write in GDB1+3, your program (or your calc) will have a problem some time, but that doesn't mean you can't write there.

But as shmibs said, what you create at compile time is quite restricting. What you can do is copying your "array" in L1 (for example) and then you'll be able to "add" or "remove" bytes from your array (as long as you don't have more than 768 bytes).
« Last Edit: October 25, 2013, 12:44:47 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: GDB's
« Reply #11 on: October 25, 2013, 01:16:26 am »
So if I wanted to store data into an "array" then add values for individual objects for instance a new object or pixlet was created. How would I "add" another value place to the "array". Btw thanks for the help.

Also I kinda figured out reading and writing to that GDB1 + 3 value the hard way. XD woops. May have crashed a couple times. it likes to change around my sprites if I write too far.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: GDB's
« Reply #12 on: October 25, 2013, 03:48:15 am »
I recommend that you use the free RAM areas. L1 for example, is 768 bytes. You can use it as you like.
Another solution if you need more space is to dynamically allocate user RAM with GetCalc. ;)

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: GDB's
« Reply #13 on: October 25, 2013, 12:28:38 pm »
Ok, so I aready know all of this, I just don't know HOW to do it.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: GDB's
« Reply #14 on: October 25, 2013, 12:39:40 pm »
[DATA -> L1

and just use L1 to call it.

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!