Hey Gang, "Ullrich von Bassewitz" schrieb im Newsbeitrag news:3io45b.qaf.ln@news.musoftware.de... > Axel Muhr wrote: > > Chris (Morse)? Adam? Any ideas, hints? Thanks in advance... > > The apple libraries don't have an implementation for the clock() function, and > therefore no CLK_TCK constant. What a thread! This grew huge since I had my last look ;-) Ok, in the meantime I've discussed a bit with Ulrich about several solutions... My first idea was VBL (like others suggested here, too), but my suggestion @ticka: bit $c019 ; Loop VBL low bpl ticka @tickb: bit $c019 ; Loop VBL high bmi tickb ; ein Tickcycle ist durch was rightfully "killed" by Ullrich, as it just counts while running (i.e. no background-counting). So my next idea was a interupt handler (coping with II,IIe,IIc and IIgs)... for googles sake, I found this old code from David Empson, which could be a basis to work from. What do you think? Cheers, Axel * VBL interrupt handler for the IIe, IIc and IIgs, for use from * Applesoft BASIC. (untested at the time of posting) * * by David Empson (dempson@actrix.gen.nz) * * This program is hereby donated to the public domain. If you distribute * it, please include the full text of the relevant portion of the original * article. jmp install ; Entry point to install the handler jmp remove ; Entry point to remove the handler mouseCN dfb $00 ; Modified to hold mouse slot in $Cn format mouseN0 dfb $00 ; Modified to hold mouse slot in $n0 format vblcount dfb $00 ; Incremented for each VBL * Routine to do the installation steps install * Locate the mouse. lda #$C7 ; Start the search at slot 7 sta $3D lda #$00 sta $3C ; Set up a pointer for the slot search sta mouseCN ; Ensure our important variables are cleared sta vblcount slotlp ldx #4 ; Set up count for lookup table bytelp lda offsets,X ; Get offset into card tay lda ($3C),Y ; Get a byte from the card cmp values,X ; Does it match? bne notmouse ; If not, this slot isn't a mouse dex bpl bytelp ; Loop back around for next byte lda $3D sta mouseCN ; Store the slot number in $Cn format tax ; and save it in X asl asl asl asl sta mouseN0 ; Store the slot number in $n0 format bne gotmouse ; Branch is always taken notmouse ldx $3D dex stx $3D cpx #$C1 ; Done all slots yet? bcs slotlp ; Loop for the next slot nomouse rts ; Return to BASIC * We have found the mouse. Set up our interrupt handler. gotmouse ldy #$13 lda ($3C),Y ; Get the location of the SERVEMOUSE routine sta doservm+1 ; Patch the call into the interrupt handler stx doservm+2 iny lda ($3C),Y ; Get the location of the READMOUSE routine sta doreadm+1 ; Patch the call into the interrupt handler stx doreadm+2 * Set up the mouse firmware. ldy #$19 lda ($3C),Y ; Get the location of the INITMOUSE routine sta doinitm+1 stx doinitm+2 ; Patch our call ldy #$12 lda ($3C),Y ; Get the location of the SETMOUSE routine sta dosetm+1 stx dosetm+2 ; Patch our call ldy mouseN0 doinitm jsr $0000 ; Patched with location of INITMOUSE * Install the interrupt handler. jsr $BF00 ; Call ProDOS dfb $40 ; ALLOC_INTERRUPT call da allocpb ; Address of parameter block bcs nomouse ; If error, forget about it * Set up the appropriate mouse mode. lda #$09 ; Mode: enable mouse, VBL interrupt only * Fall through to our setmouse subroutine. It will return to BASIC. setmouse * Subroutine to set the mouse mode to the value in A. ldx mouseCN ldy mouseC0 dosetm jsr $0000 ; Patched with location of SETMOUSE rts ; Return to BASIC or caller * Routine to disable and remove the interrupt handler. remove * Check that the install routine has been called successfully. ldx mouseCN beq noremove * Disable the mouse