Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Ki1o on October 07, 2012, 08:10:17 pm

Title: Library in an appvar?
Post by: Ki1o on October 07, 2012, 08:10:17 pm
Ok bear with me for this one... Is it possible to make a command library and place it an appvar?
Title: Re: Library in an appvar?
Post by: cooliojazz on October 07, 2012, 08:15:23 pm
Maybe it's just me, but i feel like you need a bit more detail before I could actually answer, it seems a bit ambiguous... But to answer your question, probably, yes.
Title: Re: Library in an appvar?
Post by: Ki1o on October 07, 2012, 08:20:21 pm
Let me explain by example:

Say builderboy decides to makes an interactive app or something for zedd. Would it be possible to take the commands used in the original library and put them in an appvar so when the user opens the code editor (inside of the app) he/she can write out the commands and the program would still compile?
Title: Re: Library in an appvar?
Post by: Deep Toaster on October 07, 2012, 09:11:43 pm
There is no "code editor inside of the app." People writing Axe programs use the usual TI-BASIC editor (the one you get when you press PRGM and go to EDIT or NEW).

I don't know what you mean by "write out the commands," but here's a quick rundown of the types of variables Axe uses:


See Documentation.pdf (http://axe.eeems.ca/Documentation.pdf) in the Axe download for more info.

Zedd is a library—you can just get the 8XP files from the download (http://www.ticalc.org/archives/files/fileinfo/441/44185.html) and open the programs in the TI-BASIC editor.

Does that answer your question?
Title: Re: Library in an appvar?
Post by: Ki1o on October 07, 2012, 09:47:09 pm
Well... ummm I was thinking about the way xde had a "code editor" so people could use the app instead of the standard code editor.
EDIT : 40th post I lvled up!
Title: Re: Library in an appvar?
Post by: Deep Toaster on October 07, 2012, 10:14:14 pm
XDE didn't "have" a code editor—it was (supposed to be) a code editor and nothing else.

You can make editors just like anything else in Axe.
Title: Re: Library in an appvar?
Post by: Ki1o on October 07, 2012, 10:23:01 pm
I'm sorry. One last question though. Back to the actual library part... could you put the commands in an appvar?
Title: Re: Library in an appvar?
Post by: shmibs on October 07, 2012, 10:29:01 pm
the commands ARE put in an appvar, but only for program backups, like he said. the programs that axe compiles are, and have to be, completely in the BASIC program format, with the exception of code inserted from axiom libraries.
Title: Re: Library in an appvar?
Post by: Deep Toaster on October 07, 2012, 10:29:08 pm
What would you do with an appvar?
Title: Re: Library in an appvar?
Post by: Ki1o on October 07, 2012, 10:42:36 pm
Forgive me for putting you through all this trouble. I was was experimenting with an idea I had in my head and I just wanted to know if it was possible. Sorry.
Title: Re: Library in an appvar?
Post by: DrDnar on October 08, 2012, 01:32:19 am
The Run Programs Axiom (http://www.omnimaga.org/index.php?action=downloads;sa=view;down=786) lets you call an external program (or a program typecast into an appvar) from an application. Axe variables aren't affected by the call. However, the transition in and out of the external code is pretty slow, an almost unavoidable* limitation of the OS.

*Yes, assembly programmers can come up with dozens of ways to get around that. None of them will integrate cleanly with Axe.
Title: Re: Library in an appvar?
Post by: thepenguin77 on October 08, 2012, 08:57:07 am
*Yes, assembly programmers can come up with dozens of ways to get around that. None of them will integrate cleanly with Axe.

That honestly stopped me from writing like 5 different examples he could use. But I agree with DrDnar, you'll have to call external programs.



But the real reason I'm posting is to clarify his question. I'm fairly certain he wants to use an appVar like a .dll. Basically, he wants so be able to use runtime libraries to that he can simply call them at will from his program.

So, to answer that question, no, you can't easily do that, and here's why:


While a runtime library axiom could in theory be created, you're best just to use libraries that go into the compiler (or just copy/paste the code). Also, you'll notice that in the past, all runtime libraries on the 84+ have been apps (xLib, Mirage, Doors, Celtic3) because apps can execute in place.
Title: Re: Library in an appvar?
Post by: TIfanx1999 on October 08, 2012, 11:59:07 am
Forgive me for putting you through all this trouble. I was was experimenting with an idea I had in my head and I just wanted to know if it was possible. Sorry.
I don't see that it was trouble at all. It was a good question, and drew quite a few good responses. :)
Title: Re: Library in an appvar?
Post by: Ki1o on October 08, 2012, 01:00:47 pm
thanks you all for your responses. and the penguin77, yes that was what I was thinking about but I couldn't think of a decent explanation atm. what if instead the dll was inside of the app instead of it being an external var, would that be possible? or would I need asm for that as well?
Title: Re: Library in an appvar?
Post by: thepenguin77 on October 08, 2012, 02:05:12 pm
thanks you all for your responses. and the penguin77, yes that was what I was thinking about but I couldn't think of a decent explanation atm. what if instead the dll was inside of the app instead of it being an external var, would that be possible? or would I need asm for that as well?

You could totally put it inside an app, but it's not going to be as clean as you like. You app would look like this: (asm)
Code: [Select]
;this is a comment
;jp is jump

startOfApp: ;addresses
jp routineA ;4080h
jp routineB ;4083h
jp routineC ;4086h
jp routineD ;4089h
jp routineE ;408Ch

routineA:

;blah

routineB:

;blah

routineC:

;blah

When your axe program runs in ram, it runs in the $8000-$BFFF region (not exactly, but close enough). You can then swap the library app into the $4000-$7FFF region with a bit of asm. Then, to call your subroutines, you would simply call the addresses of their jumps. I'm not exactly sure what the mechanism is in Axe, but I know you can call absolute addresses.

The real trouble would be making that app. Maybe someone better than me with Axe knows how to put a jump table in like that, but I don't. So totally possible in theory, a bit of trouble in practice.
Title: Re: Library in an appvar?
Post by: Matrefeytontias on October 08, 2012, 02:53:18 pm
Mmh, it's a pretty interesting thing to try. I think that you can define and call jump tables like that :
Code: [Select]
.your jump table
.the main problem is to make PC $4000, but I'm not sure to understand how apps work
Goto Func1
Goto Func2

Lbl Func1
.code here
Lbl Func2
.same
.etc

.then call your routines
(E4080)(args)
You can still compile your Axe jump table into an app, but the real problem is how to access the resulting app and make the code work. Maybe an axiom using _FindApp (like I did for AxeSh where I use the Axe API using Axe and Axioms, search it in the z80 projects thread).
Title: Re: Library in an appvar?
Post by: Ki1o on October 08, 2012, 04:48:11 pm
Thanks that idea is interesting. Two things though. 1. what do you mean by "PC $4000" and 2. What does E4080 mean?
Title: Re: Library in an appvar?
Post by: DrDnar on October 08, 2012, 11:43:59 pm
That honestly stopped me from writing like 5 different examples he could use.
I was totally thinking of you when I wrote that.

But also myself to a degree. Because I later had the idea that you could use Run Programs to load a program into RAM from an app, and have the app and program exchange pointers to sharable data and code using tables in scrap RAM. Of course, you'd have to jump back into the app from the RAM program, instead of returning normally; and, you'd have to use a bit of assembly (five or so bytes) to keep track of the app page. That introduces some ugliness, either requiring you to keep careful track of the stack, and making instant quit impossible without leaking memory; or, requiring some assembly code to fix up the stack and delete the RAM used, so that instant quit works right. Personally, I think the latter is the better solution, since keeping track of the order to use the code isn't too hard, I think. Does anybody want such an Axiom?

You know, it's actually do-able. You could do it the reverse way, too, using an Axiom to search for the app, and jumping into it instead of calling it from the OS. Because, you know, otherwise there's ugliness arising from the context change and all. . . .


EDIT: Right, so, to answer partially the previous post's question, PC is how the CPU keeps track of where it is in a program. Basically, each part of an Axe program is assigned an address in memory, which is just a simple number. The CPU just keeps incrementing that address, so it executes instructions in order (unless you ask it not to with a loop, conditional, or transfer). Programs are loaded into RAM at the address $9D95, whereas apps are loaded into the pageable space at $4000.

Matrefeytontias's idea of making a jump table is probably sound, but I'm not clear on what he means about changing PC. Axe apps start with PC=$4080, because the first 128 bytes are the header.
Title: Re: Library in an appvar?
Post by: Matrefeytontias on October 09, 2012, 01:37:14 am
Well, let's answer that : I've already done that. Right now, I have a Nostub Axe program using 4 functions I defined in an Axe App. And it works greatly :) I'll open a topic for that in a few minutes, just the time to make screenshots.

So, let's explain.

I have two source codes : one for the API and one for the program using it. With a rapid test (I displayed the value of a label I put as first line of the code of the API), I saw that the first instruction is at $408B.
Code: [Select]
:.AppTest
:.This is at $408B
:Goto Func1
:.This one at $408E
:Goto Func2
...

Now that I have my API, I made an Axiom on the fly including three commands :I used them to access to my API using app pages.

So, now that you know all, I post my code.
Code: [Select]
:.APIUSER
:getCurPage->P
:
:setCurPage(getAppPage("AppTest"))
:
:(E4094)(0,16,[FF818181818181FF])
:(E4097)()
:(E408E)(42)
:(E4091)(0,8,"Over 9000!")
:setCurPage(P
:getKey^r

Code: [Select]
:.AppTest
:Goto Start
:Goto Func1
:Goto Func2
:Goto Func3
:Goto Func4
:
:Lbl Start
:ClrHome
:Text(0,,"This app is an Axe lib
:Text(0,8,"You don't have to launch it.
:Text(0,16,"Press any key to quit
:getKey^r
:Return
:
:Lbl Func1
:Disp >Dec
:Return
:
:Lbl Func2
:Text(r1,r2,r3
:Return
:
:Lbl Func3
:Pt-On(r1,r2,r3
:Return
:
:Lbl Func4
:DispGraph

Like you see, it's nothing complicated :)

I'll post screenies in a new topic, so wait a moment ;)
Title: Re: Library in an appvar?
Post by: DrDnar on October 09, 2012, 05:25:19 am
Your way is definitely cleaner. I can imagine there being one reason for wanting to keep your extra code in a program---it lets users start the app, instead of the program. You're not far from writing a shell now.