Author Topic: How to use interrupts  (Read 10017 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: How to use interrupts
« Reply #15 on: September 02, 2010, 01:44:59 pm »
By the way, you should take into account that at least in normal speed (6Mhz), the Ti-83+ has more interrupts per second than a Ti-83+ silver edition does.  It's roughly 110 interrupts per second for the Ti-83+ SE, and 120 interrupts per second for the Ti-83+. 

This was only tested on Wabbitemu, so please feel free to correct me.
Could this be why on the 83+SE, most ASM games run slightly slower than on the regular 83+?

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: How to use interrupts
« Reply #16 on: September 02, 2010, 01:58:23 pm »
So if I set interrupts at a frequency of 6, how many times would it run in a second?  What unit does it mean by '6'?
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: How to use interrupts
« Reply #17 on: September 02, 2010, 02:35:47 pm »
So if I set interrupts at a frequency of 6, how many times would it run in a second?  What unit does it mean by '6'?

Unfortunately, it's not as simple as "units."

6 is the binary number 00000110.  Axe uses the 6th and 7th digits of this binary number to set an interrupt speed, because that's just the way the calculator works.  The calculator interrupt speed is set by a two-digit binary number, and Axe takes that number from the 6th and 7th binary digits of the number you specify. 

On a Ti-83+, if you specify a speed in axe of 0, the calculator reads the 6th/7th digits of the binary number 00000000 = 00, and it knows your interrupt routine should be run 560 times a second.  That's just the way the calculator works, it's a predefined interrupt speed.

If you specify a speed in Axe of 2, the calculator reads the 6th/7th digits of the binary number 00000010 = 01, and it knows your routine should be run 248 times a second.

If you specify a speed in Axe of 4, the calculator reads the 6th/7th digits of the binary number 00000100 = 10, and it knows your routine should be run 170 times a second.

If you specify a speed in Axe of 6, the calculator reads the 6th/7th digits of the binary number 00000110 = 11, and it knows your routine should be run 118 times a second.




Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How to use interrupts
« Reply #18 on: September 02, 2010, 02:37:39 pm »
OH is that how the Mirage speed settings work?




Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: How to use interrupts
« Reply #19 on: September 02, 2010, 02:47:07 pm »
OH is that how the Mirage speed settings work?

Yes indeed, which is why it doesn't work for all programs.

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: How to use interrupts
« Reply #20 on: September 02, 2010, 06:24:12 pm »
Okay, so would the following work?

Code: [Select]
.TEST
DiagnosticOff
[FFFFFFFFFFFFFFFF]->Pic1
ClrDraw
0->A->B->C->D
fnInt(SEC,6)
While 1
If C>=118
FnOff
0->C
1+D->D
Text(60,60,D>Dec)
DispGraph
FnOn
(Code to move sprite around and exit)
End

Lbl SEC
C+1->C
Return

Lbl END
LnReg
DiagnosticOn
Return

I think it should post the second while allowing me to move my sprite around.
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: How to use interrupts
« Reply #21 on: September 02, 2010, 06:34:19 pm »
Also, you are increasing health by 6 each time but checking that it's equal to the max health.  If the current health is 999 and you add 6, that's 1005 which is not equal to 1000 and the health would continue to increase.

Oh, ya, I know. It was just a quick example. Not perfect or anything like that. Just to see if my thought was correct :)
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How to use interrupts
« Reply #22 on: September 02, 2010, 06:48:34 pm »
@Michael_Lee: It should, don't know for sure, though...
Except for the fact that there should be another End.




Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: How to use interrupts - getKey confusion
« Reply #23 on: September 06, 2010, 08:07:50 pm »
The following works:

Code: [Select]
.TEST
ClrDraw
0->A->B->C
fnINT(TIM,6)
While 1
    If getKey(4)
        1+C->C
        Text(0,0,C->DEC)
    End
    If getKey(15)
        Goto END
    End
    If A>=118
        0->A
        1+B->B
        Text(0,10,B->DEC)
    End
End

Lbl TIM
    1+A->A
Return

Lbl END
    FnOff
    LnReg
    ClrDraw

It acts as a timer while allowing me to increment the variable C at whim,
but if I try doing this:

Code: [Select]
.TEST
ClrDraw
0->A->B->C
fnINT(TIM,6)
While 1
    getKey->D
    If D=4
        1+C->C
        Text(0,0,C->DEC)
    End
    If D=15
        Goto END
    End

...etc.

the getkey doesn't appear to work, or store anything to the variable D.

Meh?  What gives?

(I added indents for clarity)
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Re: How to use interrupts
« Reply #24 on: September 06, 2010, 08:55:48 pm »
I think that's because storing getkey to a pointer uses the OS interrupts and using a custom interrupt overrides the OS interrupt during program execution. Direct input doesn't rely on the OS interrupts, so that's why it works.


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: How to use interrupts
« Reply #25 on: September 06, 2010, 10:04:39 pm »
Yeah, the OS interrupt needs to be on in order to use the BASIC getkey because it has to detect when keys are pressed in the background.  You could tack on your own getkey routine for a few keys to the end of your interrupt if you really need a feature like that.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: How to use interrupts
« Reply #26 on: September 06, 2010, 11:29:03 pm »
Ahh, that would be why. 
Well, thankfully, this isn't much of a problem.

btw, can you have more then one custom interrupt running at a time?
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: How to use interrupts
« Reply #27 on: September 07, 2010, 12:20:36 am »
You can't have more than one interrupt running at once independently meaning an interrupt that interrupts the main code and the other interrupt.  But you can have multiple interrupt routines at once for different frequencies. Lets say you want one interrupt at 110Hz and one at 22Hz.  What you can do is setup a single interrupt at 110Hz (number 6) that increments a timer and when the counter gets to 5, then you call the 22Hz routine which also resets the timer.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: How to use interrupts
« Reply #28 on: September 07, 2010, 01:48:40 am »
And which frequency is the getKey command using? is it true that when I am going to add BGM, I can't use the getKey routine anymore?
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How to use interrupts
« Reply #29 on: September 07, 2010, 07:21:59 pm »
Ahh, that would be why. 
Well, thankfully, this isn't much of a problem.

btw, can you have more then one custom interrupt running at a time?

You could add code to the end of one interrupt routine that basically jumps to the beginning of the second, so that you could run just the second routine or both.