VIA T1 continuous interrupt question

Basic and Machine Language

Moderator: Moderators

Post Reply
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

VIA T1 continuous interrupt question

Post by matsondawson »

I've been having real trouble getting Bandits to run in my emulator, but I've worked out what the issue is.
Bandits uses a single continuous interrupt timer on T1, when a timeout occurs it writes a new timeout time to T1 latch low, then T1 latch high, then RTI's.
The problem is it never does any other writes or reads to the VIA to clear the interrupt bit, hence the interrupt re-occurs immediately after the RTI. I've run it in VICE and break pointed it at the Kernel Interrupt service routine at $FF72, and the "io" monitor command returns the IFR register as 0 for both vias which doesn't make sense as then how did the interrupt occur in the first place.
So the question is,
(A) why is vice showing no IFR and hence theoretically shouldn't be in the interrupt service routine.
(B) Is writing to T1L_L, or T1L_H meant to clear the interrupt flag?

I've set the code to clear the IFR on write to T1L_H and everything works fine, but that isn't what the 6522 docs say should happen.
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

Well whadya know... From the Vice 6522 code.

case VIA_T1LH: /* Write timer A high order latch */
via_context->via[addr] = byte;
update_myviatal(via_context, rclk);

/* Clear T1 interrupt */
via_context->ifr &= ~VIA_IM_T1;
update_myviairq(via_context);
break;

So T1 interrupt is cleared on a store to VIA_T1LH, but all the 6522 docs I've read say a write to T1L_H only sets the value and does nothing else!
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Previously I've read that Bandits does not work on VICE in NTSC mode due to a known but not yet solved bug about timing, something that also can affect the C64 emulation. Perhaps what you found in the source is some kind of workaround that will cover most cases?

We'd better watch out so this topic doesn't fall between Programming and Crossdeveloping. There might be a bit of Hardware into it too, since you basically are asking how the 6522 really operates - according to specs or differently. :)
Anders Carlsson

Image Image Image Image Image
Leeeeee
soldering master
Posts: 396
Joined: Fri Apr 23, 2004 8:14 am

Post by Leeeeee »

My 6522 data sheet says that ..
The interrupt flag can be cleared by writing T1C-H or T1L-H, by reading T1C-L, or by writing directly into the flag as described later.
Lee.
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

Thanks, I also just found that in the 65c22 datasheet, and this other tid bit of the internet.

>>
From: http://encyclopedia2.thefreedictionary. ... chnologies

The PET was an idea of the of the 6500 developers. It was completly developed by MOS, but was manufactured and marketed by Commodore. By the time the it was ready for production (and Commodore had cancelled all orders) MOS had been taken over by Rockwell (Commodore's parent company). Just at this time the 6522 (VIA) was finished, but the data sheet for it was not and its developers had left MOS. For years, Rockwell didn't know in detail how the VIA worked.
Bacon
for breakfast
Posts: 578
Joined: Mon Apr 19, 2004 8:07 am

Post by Bacon »

matsondawson wrote:Thanks, I also just found that in the 65c22 datasheet, and this other tid bit of the internet.

>>
From: http://encyclopedia2.thefreedictionary. ... chnologies

The PET was an idea of the of the 6500 developers. It was completly developed by MOS, but was manufactured and marketed by Commodore. By the time the it was ready for production (and Commodore had cancelled all orders) MOS had been taken over by Rockwell (Commodore's parent company). Just at this time the 6522 (VIA) was finished, but the data sheet for it was not and its developers had left MOS. For years, Rockwell didn't know in detail how the VIA worked.
I have no idea where they got that information, but not much of it is true. Rockwell never owned Commodore or MOS, but they manufactured MOS chips such as the 6522 and 6502 under license from Commodore. The PET was developed by Chuck Peddle and his team after Commodore had bought MOS. Chuck Peddle had previously developed the KIM-1 6502 single-board computer to demonstrate the 6502 (also developed by Peddle et al). After MOS became part of Commodore, Chuck Peddle convinced Jack Tramiel (Commdore's founder and CEO) that they should develop a personal computer, which became the PET.

The reason Rockwell didn't know the details of the 6522 is probably that MOS only delivered the die and not the chip layouts to their competitor.
Bacon
-------------------------------------------------------
Das rubbernecken Sichtseeren keepen das cotton-pickenen Hands in die Pockets muss; relaxen und watschen die Blinkenlichten.
Post Reply