PGOETZ@LOYVAX.BITNET (04/22/88)
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
spike@bu-cs.BU.EDU (Spike) (04/23/88)
In article <8804211832.aa02388@SMOKE.BRL.ARPA> PGOETZ@LOYVAX.BITNET writes: < < This is written for the Apple II and II+. NOT the IIe, which I have heard <can generate interrupts itself anyway. On the //c (and most likely the //e) it is call the Vertical Blanking Interrupt (VBL). It can be set by reading or writing $C05B and disabled by reading or writing $C05A. It is used by the mouse firmware, so take care in using yourself. The //c also has a Keyboard interrupt and do keyboard buffering... To turn it on: sei ;Disable interrupts lda #80 sta $05FF ;Where to put next char sta $06FF ;An where to read from lda $C0AA ;Turn on the ACIA ora #$0F ;(The serial chip in port 2) sta $C0AA cli ;enable interrupts Programs should read the buffer by calling $FD0C (RdKey). ^S and ^C will not work with buffering on. Nor will auto-repeat. Closed-Apple-^X will flush the buffer. < 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. In many cases it is best to turn off interrupts (sei) at the start of your routine and enable them as you exit (cli). The GS //c and //e use interrupts for a number of thing, it best to check the Tech. Refs to see what it handles and what it will past to you to handle... "You'll laugh, you'll cry, you'll kiss 3 bucks goodbye." UUCP: ...!harvard!bu-cs!bu-it!spike INTERNET: spike@bu-it.bu.edu CSNET: spike%bu-it@bu-cs BITNET: engemnc@bostonu "VPS sucks" -- ->Spike
scott@geowhiz.UUCP (Scott Kempf) (04/23/88)
In article <8804211832.aa02388@SMOKE.BRL.ARPA> PGOETZ@LOYVAX.BITNET writes: > > Derived from "A Clock Interrupt for Your Apple" by Charles Putney, >published in MICRO No. 62 July 1983, p. 36-41. [much useful info deleted.] >Your handler should: >1. Save the X, Y, and P registers. You don't need to save the P register. It is pushed on the stack by the 6502. This is the reason you have to use RTI rather than RTS. However it wouldn't hurt to save it. >Charles Putney's address is >18 Quinns Road >Shankill >County Dublin, Ireland >Phil Goetz >PGOETZ@LOYVAX.bitnet Scott _______________________________________________________________________________ Scott Kempf Blue itself teaches us blue. -Bill Ranson MAIL: 1302 Rutledge St., Madison, WI 53703 PHONE: (608) 255-6205 (home) UUCP: {seismo, topaz, harvard, ihnp4}!uwvax!geowhiz!scott ARPA: geowhiz!scott@spool.wisc.edu PHONE: (608) 262-6154 (work) BITNET: scott%geowhiz.uucp%spool.wisc.edu@wiscvm.bitnet
kamath@reed.UUCP (Sean Kamath) (04/24/88)
In article <8804211832.aa02388@SMOKE.BRL.ARPA> PGOETZ@LOYVAX.BITNET writes: > 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. > >Phil Goetz >PGOETZ@LOYVAX.bitnet The //e cannot do that. The //c can. I will be glad to show anyone how, along with the built in keyboard buffering the //c has. Don Lancaster in Enhancing you Apple Vol. II has a very nice routine for locking into the hires refresh start. Anyone interested, maybe I'll post in comp.binaries.apple. Sean Kamath -- UUCP: {decvax allegra ucbcad ucbvax hplabs ihnp4}!tektronix!reed!kamath CSNET: reed!kamath@Tektronix.CSNET || BITNET: reed!kamath@PSUVAX1.BITNET ARPA: reed!kamath@psuvax1.arpa US Snail: 3934 SE Boise, Portland, OR 97202 (I hate 4 line .sigs!)
james@bigtex.uucp (James Van Artsdalen) (04/24/88)
IN article <8804211832.aa02388@SMOKE.BRL.ARPA>, PGOETZ@LOYVAX.BITNET wrote: > NOT the IIe, which I have heard can generate interrupts itself anyway. Can somebody confirm this? Can the //e internally generate any kind of regular interrupt? A friend is needing something like this, and I thought the //e did not provide it. I understand that the ][gs does though. -- James R. Van Artsdalen ...!ut-sally!utastro!bigtex!james "Live Free or Die" Home: 512-346-2444 Work: 328-0282; 110 Wild Basin Rd. Ste #230, Austin TX 78746
kamath@reed.UUCP (Sean Kamath) (04/26/88)
In article <1600@bigtex.uucp> james@bigtex.UUCP (James Van Artsdalen) writes: >IN article <8804211832.aa02388@SMOKE.BRL.ARPA>, PGOETZ@LOYVAX.BITNET wrote: >> NOT the IIe, which I have heard can generate interrupts itself anyway. > >Can somebody confirm this? Can the //e internally generate any kind of >regular interrupt? A friend is needing something like this, and I thought >the //e did not provide it. I understand that the ][gs does though. >-- >James R. Van Artsdalen ...!ut-sally!utastro!bigtex!james "Live Free or Die" NO! NO NO NO NO! //e's CANNOT do this, not stock ones, anyway. It's the *MOUSE FIRMWARE* You can do a home IRQ generator. . . Couple wires and give up a pin or two. . .(on the game port. . . Have to have some way of figuring out if it's your interrupt!) Sean Kamath -- UUCP: {decvax allegra ucbcad ucbvax hplabs ihnp4}!tektronix!reed!kamath CSNET: reed!kamath@Tektronix.CSNET || BITNET: reed!kamath@PSUVAX1.BITNET ARPA: reed!kamath@psuvax1.arpa US Snail: 3934 SE Boise, Portland, OR 97202-3126 (I hate 4 line .sigs!)