Author Topic: How does one make an Axe Library, in Axe.  (Read 13907 times)

0 Members and 1 Guest are viewing this topic.

Offline josh landers

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 116
  • Rating: +1/-0
    • View Profile
How does one make an Axe Library, in Axe.
« on: March 31, 2014, 07:21:01 pm »
Could someone please explain how to make a library in axe? Because I dont know ASM and have seen examples of a library in axe anyway.  I saw it use
Code: [Select]
:..titleand haven't been able to use this header, it seems axe didnt even recognize the use of a double period.  If someone can explain how axe libraries work and how they are made that would be great!

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #1 on: March 31, 2014, 07:33:52 pm »
The fact that an Axe source file starting with two periods (a subprogram/library) doesn't show up in the compile menu is intentional. That way, you don't have subprograms and libraries cluttering up the compile menu, since it doesn't make sense to compile either as a standalone executable.


Just include prgmLIBNAME as a line in your main program and the library will be included and compiled with your main program.

Offline josh landers

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 116
  • Rating: +1/-0
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #2 on: March 31, 2014, 07:39:24 pm »
So then are the contents of the library just a collection of subprograms? Or can they be other things?

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #3 on: March 31, 2014, 08:02:13 pm »
Other than showing up in the compile menu or not, there's no inherent difference between an Axe source file that starts with one or two periods. There's nothing stopping you from using a source program that starts with one period as a subprogram or library, and if the compile menu didn't explicitly hide source files that start with two periods, you could compile those as main programs.

One important thing to keep in mind about this lack of differentiation is possible unexpected behavior in a case like the following:

Code: (prgmTESTSRC) [Select]
:.TEST
:SayHello()
:
:prgmSUB
Code: (prgmSUB) [Select]
:..
:Lbl SayHello
:Disp "Hello world!"
:Return

The execution path will, after the initial SayHello() is reached, mosey right on into prgmSUB and repeat it, due to there being no Return or other control block to stop it. So if you don't want execution to run into your subprogram/library, it's a good idea to make sure that you either include it in a place where you know execution won't naturally reach, or to make sure that your subprogram/library wraps its code in a block that will skip its execution, like If 0 ... End or Goto SubEnd ... Lbl SubEnd.

Also, a slight note: there are two quirks about inclusion of subprograms/libraries that come to mind. The first quirk is that you cannot include a subprogram/library from another subprogram/library (yet?). And the second quirk is that any changes a subprogram/library makes to the optimization target (size versus speed) will be reverted to the main program's settings when the subprogram/library is done being compiled.
« Last Edit: March 31, 2014, 08:06:04 pm by Runer112 »

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: How does one make an Axe Library, in Axe.
« Reply #4 on: April 01, 2014, 05:22:45 pm »
I lost you at the last 2 lines. But whatever  :p
I'm not a nerd but I pretend:

Offline josh landers

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 116
  • Rating: +1/-0
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #5 on: April 02, 2014, 05:59:26 pm »
Oh... ok well im off to work on my first lib! Wish me luck!

Offline josh landers

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 116
  • Rating: +1/-0
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #6 on: April 09, 2014, 04:10:43 pm »
Bump
Well its not going so well, Im not able to use a string in a routine, and for some reason it doesn't return to the parent program. It just quits. I was looking to use addresses as well like you [runner112] did in greylib, but was completely unsuccessful.
I will post some code of whats not working later but what causes this to happen runner112?

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: How does one make an Axe Library, in Axe.
« Reply #7 on: April 09, 2014, 04:37:44 pm »
Possible reasons of why it would quit instead of return to main execution :
  • You use Returnr instead of Return at the end of the subroutine.
  • You do Goto Subroutine instead of Subroutine().

Offline josh landers

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 116
  • Rating: +1/-0
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #8 on: April 10, 2014, 12:28:46 am »
Possible reasons of why it would quit instead of return to main execution :
  • You use Returnr instead of Return at the end of the subroutine.
  • You do Goto Subroutine instead of Subroutine().
x
Neither nor
I cant see why this doent work... could it have to with the fact I didnt just use r1-r6?

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: How does one make an Axe Library, in Axe.
« Reply #9 on: April 10, 2014, 12:41:08 am »
You can use whatever  variable or function within a subroutine. It'll be easier if you just post your code.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #10 on: April 10, 2014, 04:29:17 pm »
Or maybe you used neither "Goto LBL" nor "sub(LBL)" nor "LBL()" but you thought that saying "prgmPRGM" would execute PRGM and if we hit a Return "inside the program" PRGM, we go back to the "main program". But that's not the way it works. There is only one program after compilation, and saying "prgmPRGM" in your code doesn't create any level (no main program and no subprogram), it just virtually copies-pastes the contents of PRGM in your "main program" where you put "prgmPRGM".
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 josh landers

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 116
  • Rating: +1/-0
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #11 on: April 14, 2014, 12:50:31 pm »
:.header
:prgmLIB
:ACT()
:other code

:.LIBSRC
:Lbl ACT
:r1->strg111
:Return

This doesnt work!!!

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #12 on: April 14, 2014, 01:16:18 pm »
prgmLIB should be at the bottom of your source. Don't put a return in the end of it, but in the beginning. Also it should start with "..", not ".", although that's not the problem.


Like so :
Code: [Select]
:.header
:ACT()
:other code
:prgmLIB


:..
:Return
:Lbl ACT
:r1->strg111

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #13 on: April 14, 2014, 02:11:46 pm »
Well I was kinda right about the cause of the problem. And that's what Runer said when he wrote "make sure that you either include it in a place where you know execution won't naturally reach, or to make sure that your subprogram/library wraps its code in a block that will skip its execution, like If 0 ... End or Goto SubEnd ... Lbl SubEnd."

prgmLIB should be at the bottom of your source. Don't put a return in the end of it, but in the beginning. Also it should start with "..", not ".", although that's not the problem.


Like so :
Code: [Select]
:.header
:ACT()
:other code
:prgmLIB


:..
:Return
:Lbl ACT
:r1->strg111
I'd advise more to put the Return in the main program for more visibility. I just like to know where my program ends.

I am against using subprograms anyway, except for huge projects. You said it yourself in the zStart topic, you're wasting time swapping between your files, time that you could save if everything was at the same place. And you would not have problems being lost thanks to zStart's label menu. But whatever fits you I guess.
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 Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: How does one make an Axe Library, in Axe.
« Reply #14 on: April 14, 2014, 07:41:17 pm »
I'm not wasting any time currently but Illusiat is getting large and I'd rather split the source before it gets too complicated. The battle engine, map engine and game  specific code should be split anyway since it will be a modular engine.