Author Topic: Axe Q&A  (Read 590445 times)

0 Members and 2 Guests are viewing this topic.

Offline nabako

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1905 on: November 21, 2015, 05:56:05 am »
Guess I'll be using TI-Basic then.
Anyways, thank you for the quick help :)
Still a learning Axe coder, but lots of experience with BASIC :)

Offline c4ooo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
Re: Axe Q&A
« Reply #1906 on: November 22, 2015, 11:28:59 am »
Is there a tutorial for getting ans if it is a list/other var? TBh, idk what the ans var is called in the VAT :P
-German Kuznetsov
The impossible chemical compound.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Axe Q&A
« Reply #1907 on: November 22, 2015, 01:13:25 pm »
Sorry to interrupt with a different question, but when I display a token, it displays the basic token.
Like instead of displaying #Axiom( is displays AsmComp(.
Is there an easy way to display Axe tokens instead (probably by intercepting whatever Axe sends to the basic editor)?
Also, is there a way to call the OS's catalog? (I don't want to make my own.)
« Last Edit: November 22, 2015, 06:51:58 pm by E37 »
I'm still around... kind of.

Offline c4ooo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
Re: Axe Q&A
« Reply #1908 on: November 27, 2015, 04:51:06 pm »
How can i convert, in axe, a wavelength (Freq() uses wavelengths, right? :P ) into a string like "C4" or "C4♭" and back?
-German Kuznetsov
The impossible chemical compound.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1909 on: November 28, 2015, 12:51:31 pm »
How can i convert, in axe, a wavelength (Freq() uses wavelengths, right? :P ) into a string like "C4" or "C4♭" and back?

There's nothing particularly special about doing this in Axe compared to any other language. I'd imagine the part that might be a bit tricky is knowing what WAVE arguments to Freq(WAVE,TIME) correspond to what notes. If a calculator is running at normal speed (~6MHz), then this should be roughly 64000/x, where x is the desired frequency in Hz. You'd probably want to calculate these values for an octave or every note ahead of time and store them in a table.

As for converting to/from strings, that's certainly no different than how it would be done in any other language. If you call C0 the lowest note, then a note's index in a full note table is contributed to by octave*12, C=0, D=2, E=4, F=5, G=7, A=9, B=11, sharp=1, and flat=-1. If you're only storing one octave of data, then omit the octave*12 part and just multiply or divide the WAVE value for a note by 2 for every octave offset.

Offline c4ooo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
Re: Axe Q&A
« Reply #1910 on: November 30, 2015, 02:49:04 pm »
Is there a tutorial for getting ans if it is a list/other var? TBh, idk what the ans var is called in the VAT :P
To document an answer to my own question, you can get a ptr to the ans var by doing getCalc([00720000]. To load the type of the var ans into hl (axe 'ans'), do (in asm) bcall(_RclAns) \ and $1F \ ld h, 0 \ ld l, a, or Asm(CDD74AE61F260065) in hex.
The types are:
00=real, 01=list, 02=Matrix, 03=Zedaforgot, 04=String, 0C=complex, oD=complex list

If my asm is wrong someone please correct it. Zeda is the one who gave me the types list :)

Sorry to interrupt with a different question, but when I display a token, it displays the basic token.
Like instead of displaying #Axiom( is displays AsmComp(.
Is there an easy way to display Axe tokens instead (probably by intercepting whatever Axe sends to the basic editor)?
Also, is there a way to call the OS's catalog? (I don't want to make my own.)
I dont know how you call the catalog, but i when you do, the axe tokens should be there ;)
@E37
« Last Edit: November 30, 2015, 02:57:13 pm by c4ooo »
-German Kuznetsov
The impossible chemical compound.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Axe Q&A
« Reply #1911 on: December 01, 2015, 07:55:28 pm »
Thanks, I know zStart's small font program editor calls the OS's menus because they are in large font.
The tokens I was discussing referred to when they were displayed with the Text( command.
For reference I am still making my own small font program editor because zStart's is a little buggy (and to say I did).
I have made all the menus but the catalog and vars and I really don't want to rewrite the catalog (my menu code reads a list of tokens in a program which lets me create custom menus just by modifying the program).
Sorry for being unclear.
I'm still around... kind of.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1912 on: December 01, 2015, 10:13:27 pm »
Sorry to interrupt with a different question, but when I display a token, it displays the basic token.
Like instead of displaying #Axiom( is displays AsmComp(.
Is there an easy way to display Axe tokens instead (probably by intercepting whatever Axe sends to the basic editor)?
Also, is there a way to call the OS's catalog? (I don't want to make my own.)

For the record, I haven't answered either of these questions because they're beyond both my knowledge and the capabilities of native Axe. You might have better luck asking these questions framed as assembly questions in the appropriate place. The ASM board isn't particulatly active, though, so you may want to try Cemetech's equivalent (or both).

Regarding your first question, I believe the main issue is that the token hook isn't normally invoked when displaying tokens in a running assembly program. I don't know how to solve this, but if you do eventually solve it, be aware that Axe's token hook will only replace tokens if cxCurApp is $83 (and, with Axe 1.3.0, if the token hook is enabled in the options menu).
« Last Edit: December 01, 2015, 10:17:00 pm by Runer112 »

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Axe Q&A
« Reply #1913 on: December 06, 2015, 12:52:24 pm »
Oh... Darn.
To continue my long string of questions I can't seem to find the memory address of the BASIC graph.
I assume I can treat it as just another buffer.
It isn't really important I am just curious how some asm programs edit the graph.
I'm still around... kind of.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1914 on: December 06, 2015, 02:37:32 pm »
To continue my long string of questions I can't seem to find the memory address of the BASIC graph.
I assume I can treat it as just another buffer.
It isn't really important I am just curious how some asm programs edit the graph.

The graph screen buffer used by BASIC and the OS is called plotSScreen in the equate file, which is equivalent to Axe's L6, and is found at $9340.

Because many OS drawing routines operate (exclusively) on this buffer, most notably text drawing, assembly programmers generally use this as their graphics buffer. And if an assembly program doesn't explicitly mark the graph as dirty by setting the graphDraw flag, then the OS will happily retain and display whatever was in plotSScreen the next time you view the graph screen.

However, it seems that the effect of this flag was not known to most assembly programmers, so most assembly programs that don't leave an image intended to be preserved in plotSScreen still don't set this flag. And seeing garbage or the last frame of whatever assembly program ran last the next time you use the graph screen is somewhat annoying. So modern shells (at least, DoorsCS and zStart) step in and set this flag themselves, expecting that most programs run through them would have done so had their programmers known about it. But if you run an assembly program from the home screen without any shell's home screen hook enabled, you can still preserve an image.

In conclusion, an assembly program can put its own image in the graph buffer and simply not set the graphDraw flag to "request" that the OS preserve the image, but due to many programs historically doing this unintentionally, modern shells set the flag themselves to request that the OS clear the image.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Axe Q&A
« Reply #1915 on: December 06, 2015, 03:58:40 pm »
It works!
I finally understand why each of the free ram variables have a name under them!
Since L5 (textShadow) is 128 bytes each one should holds a value for each number on the screen!
And it is corrupted by ClearHome because ClearHome is the same as Fill(L5,128,0) and the same is true for L6 and ClearDraw
(My life has meaning now)

Is all of my information correct (I posted as soon as I saw this because I was excited)
Thanks SO much!  ;D
(increases karma)
I'm still around... kind of.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1916 on: December 06, 2015, 04:06:45 pm »
It works!
I finally understand why each of the free ram variables have a name under them!
Since L5 (textShadow) is 128 bytes each one should holds a value for each number on the screen!
And it is corrupted by ClearHome because ClearHome is the same as Fill(L5,128,0) and the same is true for L6 and ClearDraw
(My life has meaning now)

Is all of my information correct (I posted as soon as I saw this because I was excited)
Thanks SO much!  ;D
(increases karma)

Yes, all your information is correct. I always thought the wording in the command list about how certain things "corrupt" was rather strange, but you've got it.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Axe Q&A
« Reply #1917 on: December 07, 2015, 09:29:38 pm »
Is there an equivalent of pop and push for axe?

Realloc( doesn't seem to do anything.
I'm still around... kind of.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1918 on: December 09, 2015, 11:32:15 am »
Is there an equivalent of pop and push for axe?

In general, there isn't. And this is for a number of reasons. To name a few: it's too low level of a concept to belong in a compiled language; checking if pushes match pops could prove tricky; the compiler uses the stack for its own purposes and would often interfere with the user trying to use the stack; and, although Axe isn't currently good enough, a good optimizing compiler would use the stack like you're imagining anyways.

However, when posed with requests like this long ago, Quigibo thought of a great implementation for simpler cases that avoids all these problems. Select(A,B) is a command that simply returns A. Each arguments to a built-in Axe command/function except the last is saved by being pushed onto the stack, so A is pushed onto the stack after being evaluated. You can then perform any single expression in B, the result of which is kept in hl. Finally the body of the command is executed, which simply performs pop hl to restore the value of the first argument.

Realloc( doesn't seem to do anything.

If you mean it doesn't correspond to any compiled code, that's correct. It redefines the pointers to the letter variables, and changing these compile-time values doesn't result in any runtime code.

If you mean it literally doesn't do anything, then that's a bug. But it seems to work for me in both Axe 1.2.2 and 1.3.0.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Axe Q&A
« Reply #1919 on: December 09, 2015, 05:19:14 pm »
I meant that Relloc( didn't seem to perform a function like pop or push.
I was just curious if there was a way to reuse letter variables.
I'm still around... kind of.