Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!pasteur!ucbvax!LOYVAX.BITNET!PGOETZ From: PGOETZ@LOYVAX.BITNET Newsgroups: comp.sys.apple Subject: 60 Hz interrupt mod Message-ID: <8804211832.aa02388@SMOKE.BRL.ARPA> Date: 21 Apr 88 20:57:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 65 Derived from "A Clock Interrupt for Your Apple" by Charles Putney, published in MICRO No. 62 July 1983, p. 36-41. This is written for the Apple II and II+. NOT the IIe, which I have heard can generate interrupts itself anyway. Chips might have different numbers/locations in other models, or might not be present. The old Euro-Apple has different counters (because European screens have a different scan rate), so this mod won't work on them either. Basically, this mod steals a periodic signal off the board & sends it to the 6502's IRQ line. Counters D11, D12, D13, & D14 generate the horizontal byte position & vertical line position on the screen (to feed the proper video info out). Connect pin 11 of D11 (the chip to the right of the middle row of RAM) to Pin 4 of H7/8 (the 6502). 30-gauge wire-wrap wire is best. Lift the pins enough to insert the wire along with the chip. This way you can remove the wire easily. This provides ~60 interrupts per second (59.92 on Putney's Apple). Putney claims this will add only 2.9% interrupt-processing overhead to a running program. He suggests several applications: keep track of time, as a keyboard buffer, or as a print spooler. I think you could also implement multi-tasking, though you might have to swap page 0 in & out between tasks. The article contains a clock program and keyboard buffer. I can't send them out because they're copyrighted. (For any lawyers out there: What happened to MICRO's copyrights since they went bankrupt? Did they revert to the authors?) The IRQ (Interrupt ReQuest) line, as opposed to the NMI (Non-Maskable Interrupt) line, only registers an interrupt if the interrupt disable bit (bit 2) of the processor status byte is clear. Clear it with a CLI ($58), set it with a SEI ($78). If this request is received, the processor jumps thru a vector at $FFFE, which points to $FA86 in the II and $FA40 in the II+. This routine saves the accumulator (A) in $45?. Then it jumps through $3FE to your interrupt handler. Your installer should: 1. Point $3FE at your handler. 3. SEI (Putney's program does this: LDA LO+1; EOR #$20; STA LO+1; LO: SEI. That way the first call does a CLI & the second call does a SEI.) 4. RTS Your handler should: 1. Save the X, Y, and P registers. The A reg is saved in $45 (not a good place, I think it could cause trouble with DOS) by $FA40. DON'T save them using the monitor IOSAVE routine, because internal functions use the IOSAVE routine, and interrupting them would screw them up. 2. Do whatever. 3. Restore X and Y, load A from $45, load the processor status (P) register. 4. RTI (not RTS). Payton mentions that a keyboard buffer, which clears $C010's hi-bit, will not work with programs which check $C010 for a keypress. He must mean $C000, because checking $C010 would tell the apple to throw away the last keypress. If a program looks like LDA $C000; BMI NO_KEYPRESS, and your keyboard buffer interrupt program is busy buffering keypresses & accessing $C010 to clear the hibit of $C000, the program will miss many keypresses, the ratio depending on how fast it is. Note that if you write an interrupt handler which takes more than 1/60 of a second, you will be caught in an infinite loop. Charles Putney's address is 18 Quinns Road Shankill County Dublin, Ireland Phil Goetz PGOETZ@LOYVAX.bitnet