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

0 Members and 4 Guests are viewing this topic.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1605 on: April 07, 2013, 03:51:37 am »
There won't exactly be a queue. Only one timer request can be "waiting", but as soon as the interrupt finishes, the timer request will be acknowledged and the interrupt will recur. So you won't get a stack build-up and overflow of waiting calls, but you will get an infinite loop of your interrupt running over and over.

And yes, executing interrupts at exact frequencies is a pain in Axe. But unfortunately there isn't much the language can do about it, because it's restricted to the limited number of speed settings the timer hardware provides. There are no exact multiples of 60Hz so you can't get it exactly, and the fastest speed is about 1000Hz so it's hard to get it almost exactly as well.

Offline Caustic

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1606 on: April 07, 2013, 05:08:04 am »
How long does Pause 1 actually last?

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Axe Q&A
« Reply #1607 on: April 07, 2013, 05:17:32 am »

And yes, executing interrupts at exact frequencies is a pain in Axe.

i keep misreading this as "pain in the axe" :p

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1608 on: April 07, 2013, 12:24:04 pm »
How long does Pause 1 actually last?

This is one of the reasons I took it upon myself to start documenting the size and speed of Axe commands. If you open up Commands.html, select one of the "Show size and speed for" buttons, and find Pause, you will see that it takes approximately 3349*n cycles. The calculator normally runs at 6MHz, so you can figure out the time if you like.

However, that formula is not quite accurate, especially for small values of n. If (on a desktop browser) you hover your mouse over the speed information, you'll get a messy formula that exactly describes the number of cycles Pause takes. In the case of Pause 1, it's actually very hard to determine. Pause basically runs a loop inside of a loop, with the outer loop running the number of times you specify. But Paues was really designed for larger values where a small difference of one or two thousand cycles wouldn't matter, so for the sake of size optimization, on the first outer loop iteration, the inner loop iterates a number of times according to whatever value happened to be sitting in one of the CPU registers at the time. This first outer loop iteration, which in the case of Pause 1 is the only outer loop iteration, can run anywhere from 8 to 3349 cycles; all the following outer loop iterations will run at exactly 3349 cycles. You'd need to look at the disassembly of the code leading up to the Pause command and determine what value will be held in the b register (and sometimes it cannot even be determined) to know how long the first iteration will take, but that's probably overkill for now.

If you want to pause for a very small, precise amount of time, I would suggest something like the following:
Code: [Select]
For(N)
End
This block of code just executes an empty loop N times, and it will do so at about 13 cycles per iteration.

Offline Caustic

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1609 on: April 07, 2013, 01:14:42 pm »
Incredible, thank you for addressing all my questions. I really spent the whole day scratching my head over grayscale.
*Tosses over ambitious 4 level grayscale RPG-adventure-harvestmoon-simcity-eveonline game into bin.

I wonder if programming asm on calc is practical enough, I don't really feel like using a modern computer to assist me...
I'm sure I can find it if I could actually search the forums, because the native search bar here is disabled for me. :(
« Last Edit: April 07, 2013, 01:15:48 pm by Caustic »

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1610 on: April 07, 2013, 01:27:47 pm »
If you're interested in on-calc assembly coding, probably the best tool for that is Mimas.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Axe Q&A
« Reply #1611 on: April 07, 2013, 01:39:53 pm »
Also to search : http://megapowers.net/v/search.htm
Forum search is completely disabled because of lag. It was really slow anyway. ;)

Offline Caustic

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1612 on: April 07, 2013, 02:03:41 pm »
Also to search : http://megapowers.net/v/search.htm
Forum search is completely disabled because of lag. It was really slow anyway. ;)

Love at first sight, thanks for the link, runner, though you got ninja'd by a certain search engine. Dp forgove the strange order of the paragraph. You may blame the creators of the search egine for amking a terrible operating system. I cant even read what Imm writimg stm. Thanks for the suggestion by I just used some Google syntax to do it. It wasn't that I couldn't search the forums, it was just a hassle to switch tabs on a plastic brick that makes my calculator feel like one of IBM'S supercalcs... er comps, whatever the difference is.
If you're interested in on-calc assembly coding, probably the best tool for that is Mimas.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Axe Q&A
« Reply #1613 on: April 08, 2013, 04:54:55 am »
There is also <a href=http://ourl.ca/14654/274550>ASMDREAM</a> for writing ASM programs on calc. You might want to give it a look as well. ;)
*Edit* you could also go the route Xeda does and write the programs out in hex. :P
« Last Edit: April 08, 2013, 04:55:47 am by Art_of_camelot »

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Axe Q&A
« Reply #1614 on: April 08, 2013, 07:46:18 pm »
If you want to pause for a very small, precise amount of time, I would suggest something like the following:
Code: [Select]
For(N)
End
This block of code just executes an empty loop N times, and it will do so at about 13 cycles per iteration.
Does the push bc \ pop bc get auto-optimized or something?
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1615 on: April 08, 2013, 07:47:00 pm »
If you want to pause for a very small, precise amount of time, I would suggest something like the following:
Code: [Select]
For(N)
End
This block of code just executes an empty loop N times, and it will do so at about 13 cycles per iteration.
Does the push bc \ pop bc get auto-optimized or something?

Indeed it does. Axe isn't great at optimizing, but it isn't terrible either. :P
« Last Edit: April 08, 2013, 07:47:31 pm by Runer112 »

Offline Caustic

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1616 on: April 11, 2013, 02:17:12 pm »
Right now I'm making (yet another, but even "yet another" is taken) shmup bullet hell game. I'm quite impressed with the amount of data Axe can handle at once, but I've hit a dead end. I think I tackled the initial problem of storing bullet data like how anyone would, in the safe RAM areas, every 6 bytes account for one bullet, as x, y, dx and dy. Enough of boring you with things you are well familiar with, how do I search for empty 2-byte elements in a buffer? Or to solve (and ruin) my solution, what is the most effective way of replacing bullets that have gone offscreen with newer bullets?

Right now, my main loop involves going through every six bytes in the designated buffers, adding dy dx to x and y, and finally check if it's out of screen, and making it zero. The loop ignores data when x + y = 0.

If I need to elaborate further for your benefit, do ask.
« Last Edit: April 11, 2013, 02:19:26 pm by Caustic »

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #1617 on: April 11, 2013, 02:29:56 pm »
There's a pretty ingenious (at least I thought so when I learned it years ago) way to handle this. Keep track of the total number of bullets with some variable. When you add a bullet, increase the bullet total and put the new bullet at the end of the list of bullets, which should be at the memory location old_total*6+list_start. This all probably seems pretty standard. But the trick is in bullet removal: decrease the bullet total and move the data for the last bullet in the list into the position of the bullet that was just removed. In Axe, the code for that might look something like this:

Code: [Select]
.Deletes the bullet at index r₁ (0-indexed)
.Updates bullet total N
Lbl Del
Copy(N--*6+<list_start>,r₁*6+<list_start>,6)
Return
« Last Edit: April 11, 2013, 02:30:38 pm by Runer112 »

Offline Caustic

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1618 on: April 11, 2013, 02:40:49 pm »
There's a pretty ingenious (at least I thought so when I learned it years ago) way to handle this. Keep track of the total number of bullets with some variable. When you add a bullet, increase the bullet total and put the new bullet at the end of the list of bullets, which should be at the memory location old_total*6+list_start. This all probably seems pretty standard. But the trick is in bullet removal: decrease the bullet total and move the data for the last bullet in the list into the position of the bullet that was just removed. In Axe, the code for that might look something like this:

Code: [Select]
.Deletes the bullet at index r₁ (0-indexed)
.Updates bullet total N
Lbl Del
Copy(N--*6+<list_start>,r₁*6+<list_start>,6)
Return

Thank you so so much for your quick reply, as always. But I feel so cheap having such an obvious (albeit impressive and practical) solution spoonfed to me... ;_; it's figuring out these solutions that make programming such a wonderful experience.

Thanks again, anyhow. O(^^O)

Edit: Modern Smartphones are so good at the one or two things they should do, like typing a forum post without subtly sneaking a typo or two in.
« Last Edit: April 11, 2013, 02:46:04 pm by Caustic »

Offline rampadc

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 5
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1619 on: May 01, 2013, 03:30:45 am »
Quick question, is there a way to loop through static variables? For example, I have 19 sprites Pic00, Pic01, Pic02,...,Pic18, and I'd like to display them horizontally across the screen (until it reaches the edge and go to the next column).

I've read somewhere that you can use
Code: [Select]
For(I,0,18)
Pt-On(X,Y,Pic00+I)
End

But all I got is the first sprite pressed down and spread across the screen (think of butter or shift drag in MSPaint).