Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Matrefeytontias on October 09, 2012, 02:39:09 am

Title: A new way to use subroutines : why not in an app ?
Post by: Matrefeytontias on October 09, 2012, 02:39:09 am
Hi guys !

I was wondering with other members (including DrDnar and thepenguin77, it started here (http://ourl.ca/17169)) how possible it was to define subroutines in an Axe program called into an app and call them from another classic Axe program.

So, I can say that it's possible since I did it :D

(http://mattias.refeyton.fr/espace-ti/funcsFromApp.gif)

I used an Axiom I programmed on the fly called PageSwap ; it provides three functions to work with pages.

FunctionPrototypeEffect
getCurPage
Token : R>Pr(
getCurPageReturns in HL the current page
setCurPage(
Token : R>P?(
setCurPage(PAGEMake PAGE the current page
getAppPage(
Token : P>Rx(
getAppPage("APP"Returns the page of the app, or the current page if not found
appFunc(
Token : P>Ry(
appFunc(NUMReturns the adress of the NUMth func in the app. Then you can call it with (EXP)(ARGS) (make sure that you're not calling the Start func ! Also make sure that you're effectively in the app before calling funcs)

You'll find these func in the Angle menu [2nd] [apps].

Share comments :)

EDIT : added a fourth function to easily call subroutines inside an app.
Title: Re: A new way to use subroutines : why not in an app ?
Post by: DrDnar on October 09, 2012, 05:37:58 am
This is nice work. Now you can write a shell in Axe.

Be forewarned: this will not play nice with Axe Fusion.

Also, there's the slight problem that it depends on Axe not changing the structure of its app initialization code. Fortunately, that's unlikely, and you can just keep using the old compiler for updates if such happens.
Title: Re: A new way to use subroutines : why not in an app ?
Post by: thepenguin77 on October 09, 2012, 08:04:38 am
I agree, excellent work.

Just watch out for commands that place themselves at the start of an app (though I'm not sure these exist).


The next step now is to make an app like this that runs a 24KB program that runs fullrene. 40KB of executable code!!! (As opposed to the library approach)
Title: Re: A new way to use subroutines : why not in an app ?
Post by: TIfanx1999 on October 09, 2012, 09:01:16 am
Nice work here, very cool stuff. On another note, I've heard that Axe fusion is pretty broken at the moment, so it shouldn't be an issue *yet*.
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Matrefeytontias on October 09, 2012, 09:56:17 am
Yeah, I thought so. But anyway I hadn't planned to use Axe Fusion with that, I already knew that it had trouble with everything out the current program (like vars).
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Matrefeytontias on October 09, 2012, 01:04:00 pm
Update !

I added a new command to the axiom in order to make the call of the app functions easier ; just check the screen, I updated it, as for the attachment :)
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Ki1o on October 09, 2012, 05:58:13 pm
Well I didn't expect this at al... I have a question though.  Would it be possible for the API to be compiled along with the calling program?
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Yeong on October 09, 2012, 05:59:51 pm
Well, due to my lack of knowledge, I can't understand what this axiom achieves D:
Title: Re: A new way to use subroutines : why not in an app ?
Post by: DrDnar on October 10, 2012, 12:53:38 am
The idea is simple: You can now write an Axe app and an Axe program, and the program can call routines stored in the app. Since apps can be up to 16 K, and programs up to 24 K, you can now write combination Axe programs/apps with up to 40 K of combined code and data. (And if you need even more, there's still the files interface.)
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Matrefeytontias on October 10, 2012, 01:15:36 am
And you can also access several apps with a single program, which means a nearly unlimited amount of code =)
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Ki1o on October 10, 2012, 06:52:59 am
I think you may have unconsciously made 2 page apps possible.
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Xaychru04 on October 10, 2012, 08:50:06 am
That could be very interesting !
And do you have to recompile the apps you need to compile the Axe program ?
If not, It can be faster to recompile programs that just changed a little...
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Matrefeytontias on October 10, 2012, 10:33:08 am
You only have to recompile the programs you changed :)
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Xaychru04 on October 10, 2012, 12:29:50 pm
So that could be very interesting :D
Title: Re: A new way to use subroutines : why not in an app ?
Post by: DJ Omnimaga on October 31, 2012, 03:24:00 pm
Wow seems very nice. This will definitively be handy for those with big RPGs and such files with complex engines. Is it fully useable yet or is it still very buggy?
Title: Re: A new way to use subroutines : why not in an app ?
Post by: DrDnar on October 31, 2012, 06:37:09 pm
It works fine, as long as you know what you're doing. That means keeping track of what app page is active and making sure you reset the current app page to the correct value before returning. This applies even if you ran the program from the OS, which still has associated fixed app pages. Also, still no multi-page app support.
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Hayleia on November 01, 2012, 03:37:55 am
I just thought about something stupid. We could make Axe librairies using this Axiom O.O
We could make apps with a lot of useful routines inside (they could be hybrid Axe/ASM for more speed) and then users could code easier. I think that would be great for newbies since they would learn by coding and would not be afraid by the task of making a tilemapper :D
The only problem would be the side. Will anyone really use 16384 bytes of routines and still have some more code ? o.o°
(except if all newbies start as I did and make Pokemon as their first project :P)
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Matrefeytontias on November 01, 2012, 06:30:31 am
@DJ_O It's fully useable and doesn't contain any bug if you use it correctly ;) Just respect the format I described in the first post for your apps and it'll be ok.

@Hayleia good idea, it's just that newbies will have a hard time with pages :/
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Xeda112358 on November 04, 2012, 07:53:15 am
What if you made an app with about 300 routines. These could be tilemapping routines, floating-point math routines, Input routines, Menu( routines, different text routines using different fonts, math parsing (so that users could input equations and stuff), arbitrary precision math, matrix and vector support, and all sorts of other goodies. Then, you can make an axiom with three commands:

OpenLib (This basically finds the app and swaps the page in MemBank1 so that routines can be called directly)
ExitLib   (This will put the appropriate page back in MemBank1 and must be called upon exiting the program)
ExecLib  (This will allow you to execute functions in the app)

This could easily fit into one app page and provide the kind of tools that would make it amazing for math. Heck, you could build a CAS if you were motivated enough :P
Title: Re: A new way to use subroutines : why not in an app ?
Post by: Matrefeytontias on November 04, 2012, 08:06:46 am
Hm, yeah, I'll change the already existing funcs into these ones. Good idea ;)

But no, I can't build a CAS even if I'm motivated :P
Title: Re: A new way to use subroutines : why not in an app ?
Post by: aeTIos on November 05, 2012, 09:42:25 am
Wow I just understood what this axiom makes possible O.O I really could use this. (which is an understatement)