I need to know if this is possible:

I code an engine for a generic game authoring thing. I have it load data from an appvar and run a game based on that. I want to have users add their own code to be called as specified in the data (i.e. AI code to control enemy movement). So the data would specify an offset, and the method would be called when triggered by the engine. The question I have here is: how would I have the function call methods in the engine? Keep in mind that this would all be in axe, so I would need to find a way to compile it with the engine code, and then separate it from the engine code and package it into the appvar. Keeping in mind that this isn't how it would be used irl, is this possible?
Well, you could perhaps have code that has a general position address of $8000 (so that code relatively thinks it's starting at around $8000) and compile it into a program. Then, just change it on-calc using something like CalcSys to an Application Variable. You could then load the library and call to it like so:


Code:
Copy(GetCalc(appvLIBRARY), e8000, 1000)
(e8000)()


Then, be sure you call "bcall(_fillBasePageTable)" (Asm(EF1150) inlined assembly) after using the library to clean up the buffer at $8000. Restrict yourself to only 1000 bytes of code to stay safe.

This is a complicated way to achieve it, and it's not tested obviously, but that's my take on what it might entail.
I don't think that Axe has the equivalent of assemblers' .org, so compiling to any address other than $9d95 (programs) or $4080 (apps) isn't possible with the current versions. You do have the right idea, though, Ashbad.
calcdude84se wrote:
I don't think that Axe has the equivalent of assemblers' .org, so compiling to any address other than $9d95 (programs) or $4080 (apps) isn't possible with the current versions. You do have the right idea, though, Ashbad.


Well, I was actually thinking from his IRC discussion that his "DLL"s would be written in pure assembly -- but yes, writing them in Axe would be a huge PITA Sad
Ashbad wrote:
calcdude84se wrote:
I don't think that Axe has the equivalent of assemblers' .org, so compiling to any address other than $9d95 (programs) or $4080 (apps) isn't possible with the current versions. You do have the right idea, though, Ashbad.


Well, I was actually thinking from his IRC discussion that his "DLL"s would be written in pure assembly -- but yes, writing them in Axe would be a huge PITA :(


Shoot. I was hoping to be able to do that. Now I'll either have to write this in asm, or make a new language to deal with it... Now that I think about it, an interpreted language wouldn't be too hard for this situation... especially as it will be single-purpose. Maybe just "run(function)" would be all it needed...
seana11 wrote:
Shoot. I was hoping to be able to do that. Now I'll either have to write this in asm, or make a new language to deal with it... Now that I think about it, an interpreted language wouldn't be too hard for this situation... especially as it will be single-purpose. Maybe just "run(function)" would be all it needed...


But then wouldn't just be "scripting", not "dynamically linking"/"dynamically running"? It would hurt the performance greatly (and even more so the size -- you'll now need to pack a whole interpreter with your program to work with that external code!) so while that is an interesting idea, I don't think that's the best real alternative to this problem.

I guess, it's possible, to comb over the Axe-output binary to change addresses around, but that's just painful; perhaps you could just run it as another program using the built in program-running syscalls? (though, I think that would only really work from within a flash application)
Well, he could get around that by placing *his* code elsewhere in RAM and just hardcoding a massive buffer into the code so that it's compiled properly. Another method would be to have the user set flags, then "link" the program at initialization with a bootloader of sorts.
Ashbad wrote:
seana11 wrote:
Shoot. I was hoping to be able to do that. Now I'll either have to write this in asm, or make a new language to deal with it... Now that I think about it, an interpreted language wouldn't be too hard for this situation... especially as it will be single-purpose. Maybe just "run(function)" would be all it needed...


But then wouldn't just be "scripting", not "dynamically linking"/"dynamically running"? It would hurt the performance greatly (and even more so the size -- you'll now need to pack a whole interpreter with your program to work with that external code!) so while that is an interesting idea, I don't think that's the best real alternative to this problem.

I guess, it's possible, to comb over the Axe-output binary to change addresses around, but that's just painful; perhaps you could just run it as another program using the built in program-running syscalls? (though, I think that would only really work from within a flash application)


No, I mean not axe code. I'm talking about /very/ application specific code, with /very/ limited features. Just enough to call the required routines and have some conditionals and such.
well, for calling just some simple routines in the "DLL" using the $8000 method above, you could just call them using


Code:
(GetCalc(appvLIBRARY)+offset)(Arguments)
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement