Jump to content
IGNORED

IRQ Questions - Keyboard and Pokey Timers


peteym5

Recommended Posts

I am working on adding a pause to a game I am working on, but trying to do it with IRQ instead of polling inside of the VBI to save CPU time. It works for the most part, but the game also plays some 4bit sound samples and it is crashing from time to time. The RTI sometimes sends the program somewhere not part of the main program area after the sound plays, even if I never hit pause. I disable the keyboard IRQ while playing a sound, but didn't help much. Wouder if there is a POKEY register I have to do to clear the last key pressed or something.

Link to comment
Share on other sites

You only have to disable/re-enable the key IRQ same as most others.

 

This problem sounds much more like the stack level is wrong, ie you're pushing different # of registers than you're pulling. If you're using vectors ~ $200 area then the OS might have pushed a different number of registers depending on what vector you use.

Link to comment
Share on other sites

It works for the most part, but the game also plays some 4bit sound samples and it is crashing from time to time. The RTI sometimes sends the program somewhere not part of the main program area after the sound plays, even if I never hit pause. I disable the keyboard IRQ while playing a sound, but didn't help much. Wouder if there is a POKEY register I have to do to clear the last key pressed or something.

Not in this sense. To indicate that you handled the IRQ, you need to clear the keyboard IRQ. For that, write first #$bf to IRQStat ($d20e) which resets the IRQ. Then write again a mask into IRQStat to indicate which IRQs you would like to receive.

 

The reason why your program crashes "sometimes" might be because you're running out of stack. What may happen is that your interrupt interrupts itself - happens if interrupts happen too often - and at a certain point overwrites its return address. Consider for example the case where your IRQ is interrupted by the VBI, which is then again interrupted by the next IRQ if you're depending on the pokey timer, for example.

 

One notice: The Os will already save the accu on the stack for you, that is, you should return with a PLA RTI from your code, not with an RTI alone.

Edited by thorfdbg
Link to comment
Share on other sites

I disabled the OS and using a custom routines. I was changing the IRQ vector addr while playing a sound. I originally designed all the IRQs to be starting on the same memory page so I just have to change the IRQ vector low. I discovered the keyboard IRQ was pushed up into the next page and was possibly causing the issue. I copied and pasted the routines around and seems to be working better. I did try some register saves to memory instead of using the stack.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...