VRC7 cycle timer IRQ - won't run for me

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

VRC7 cycle timer IRQ - won't run for me

Post by Ben Boldt »

Hi guys, I am doing a little bit of a hack here to play something using VRC7 expansion audio. I got 1 note to play without much trouble. I noticed in the VRC7 wiki for register $9030, it says:
After writing to this register, the program must not write to $9010 (or $9030 again) for at least 42 CPU clock cycles while the VRC7 internally handles the write.
I understand most/all emulators won't enforce the minimum 42 cycles. But since I would like this to potentially work on a real VRC7, that made me think about the most efficient way to write lots of stuff to these registers without tons of 42-cycle burns all the time. I thought I would make a circular buffer in RAM to queue up the register writes, then use the VRC7's IRQ to service the queue. So that is the story how I got to the IRQ problem.

Basically I write a $07 to register $F000, and I never, ever get an IRQ. I also tried writing to the IRQ Acknowledge register $F010 with no improvement. From everything I can tell, that is all I should have to do is write 7 to f000 and it should get an IRQ within 256 cycles, and it just won't do it, very stubborn this one. Anyone familiar what more I might have to do? I attached the source and assembled ROM file if it could help.
Attachments
test_rom.zip
(7.65 KiB) Downloaded 129 times
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: VRC7 cycle timer IRQ - won't run for me

Post by Ben Boldt »

Oh man, I never did a CLI instruction to enable interrupts on the 6502 end. Well, never mind, it works now.

Literally I spend an hour trying to figure that out and the moment I post it here I figure it out. LOL :roll:
User avatar
za909
Posts: 249
Joined: Fri Jan 24, 2014 9:05 am
Location: Mijn hart woont al in Nederland

Re: VRC7 cycle timer IRQ - won't run for me

Post by za909 »

Even though the issue was minor, I'd be interested to know how much you can save by doing register writes like that. There might not be 42 cycles of IRQ-related overhead, but I can't imagine there being a huge benefit (acknowledge/restart cycle counter, + getting in and out of the IRQ). It would also complicate things if you wanted to use the cycle counter for other purposes.
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: VRC7 cycle timer IRQ - won't run for me

Post by Ben Boldt »

Sorry I had not seen your message earlier. Yes, I agree that the IRQ is not an efficient way to do this at all. In fact, I tested with just an infinite loop servicing the buffer, and that had enough delay all on its own! Pretty terrible. I am actually thinking it probably takes enough cycles delay just pushing into that queue to begin with. Not to mention the RAM it eats up. My best bet is probably to remove the queue and just do some smart cycle burns as necessary.
Post Reply