Author Topic: programming help?  (Read 2830 times)

0 Members and 1 Guest are viewing this topic.

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
programming help?
« on: September 08, 2011, 09:17:50 pm »
Could someone please direct me or explain to me what all the brackets, lists, and r1-6 's are? I am a basic programmer, currently making the switch to axe. Thank you!

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: programming help?
« Reply #1 on: September 08, 2011, 09:28:36 pm »
Quick summary before I'm ninja'd:

Brackets enclose Hexadecimal to be inserted directly into the program. For example:

Quote
[0123456789ABCDEF] →Str1

Stores the hexadecimal 0x0123456789ABCDEF somewhere in the program, then sets the value of Str1 equal to address of the memory location it's stored at (i.e. makes Str1 a pointer to the hex).

Lists are even more simple than brackets. Basically, they're sections of free memory that you can use in your program without explicitly allocating them. Just use L1-L6 as pointers to memory. The sizes of those sections (aka buffers) can be found in the html command documentation.

If any of the above is confusing or you aren't familiar with the terminology, just ask :)

Welcome to the forums.
« Last Edit: September 08, 2011, 09:29:18 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: programming help?
« Reply #2 on: September 08, 2011, 09:28:56 pm »
You may be interested in our extensive collection of Axe Parser Tutorials:

http://www.omnimaga.org/index.php?action=articles;cat=12

Browse around there, there really is a whole bunch of useful stuff.

Also, be sure to check out the Axe Documentation.pdf file, the Commands.html file, and stuff like that. The commands.html file isn't so thorough, but it explains all the commands you can use, and gets you started so you can experiment with test-like programs to really figure stuff out. I remember reading about r1-r6 in Commands.html and thinking, uh, what? But it was all I needed to know to experiment and figure out what it meant.

Good luck :)

EDIT: Also, in case you don't already know, r1-r6 are found by pressing [vars]
[3] or something like that.
« Last Edit: September 08, 2011, 09:30:24 pm by buttsfredkin »
Completed Projects:
   >> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
   >> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.


Spoiler For Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)



Offline mrmprog

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 559
  • Rating: +35/-1
    • View Profile
Re: programming help?
« Reply #3 on: September 08, 2011, 09:49:13 pm »
Welcome to the forums! The Axe documentation is a very good place to start. It can be overwhelming at first, especially some of the lower level stuff, but if you keep working at it, it will all become clear. The way I learned was by experimentation. I would look up something in the command list, and then try it. If you do this though, expect a few many ram clears  ;)

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: programming help?
« Reply #4 on: September 08, 2011, 10:13:04 pm »
I would highly recommend you look up pointers.  They're basically related to low-level manipulation of memory.  Googling it would pull up a bunch of explanations in C/C++, so ignore the specifics of the syntax and focus on trying to understand the concept.

Code: [Select]
.TEST

Text(0,0,L1>Dec)
Pause 1000

(The '>Dec' token can be found in the number menu).

L1 can be thought of as a constant that tells you the start of some free memory you can much around in.  Let's say (hypothetically speaking) that running the above program displayed the number '541'.  That means that starting from the 541th byte in RAM, you have (according to the documentation) about 700 bytes to play around in -- from the 541th byte to about the 1241th byte (give or take a little).

If you want to store anything to those bytes, you use curly brackets.

Code: [Select]
.TEST2

3->{L1}
4->{L1+5}

Text(0,0,{L1}>Dec)
Text(0,8,{L1+5}>Dec)
Pause 100

This would store the number '3' to the 541th byte, and the number '4' to the 546th byte, and display first the number '3' then the number '4'.

Finding a segment of free memory (by using this method, or by allocating program memory/making an appvar, which is more complicated), is the only way you can have lists or arrays in Axe.

Sometimes, though, you just don't have enough free RAM to be able to do anything complex.

You can use square brackets to store raw data directly into your program.

Code: [Select]
.TEST3

[01020A0B]->P
That would store a bunch of hex (in this case, exactly 4 bytes), and store the pointer to the variable P.

If I did...

Code: [Select]
.TEST4

[01020A0B]->P

Text(0,0,{P+2}>Dec)
Pause 1000
That would display the 3rd byte (indexes start at zero), which would be the number '10' (in hex, 0A is ten).

This is a good way to store and read, say, a tilemap or level data.

r1 to r6 are variables, just like A, B, C, and D.  If you pass values to functions, they'll be stored to r1 to r6.

Also, one thing that tripped me up when I started Axe -- you don't need curly braces to store and read from simple variables like A, B, or r1.
« Last Edit: September 08, 2011, 10:15:18 pm by Michael_Lee »
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: programming help?
« Reply #5 on: September 09, 2011, 11:38:16 am »
In fact, trying to do {A} will just get you the Ath byte. In case you're using 0.5.3b and run out of vars, There are Axe's secret Vars, X/Yt1-3, accessible under the Parametric section of the Y-VARS menu that comes up when you press the VARS button (sorry if I'm overexplaining)
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!