Lowering the priority of the IKBD interrupt

From Atari Wiki
Revision as of 09:21, 26 July 2008 by Simonsunnyboy (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Wikified by Simon Sunnyboy / Paradize

Sometimes you have raster effects on Timer B and you do not want to stabilize them by killing all other interrupts which would force you to implement your own IKBD reading routine.

Atari officially used a very similar code to the following to stabilize Timer Bs in their STE programmer's guide from 1989.

The idea is to lower the interrupt priority of the IKBD interrupt when called. Timer B gets serviced first and rasters stabilize. And: all BIOS routines for reading the keyboard stay intact. This means, GFABASIC coders like me can still use INKEY$ an INP(2) to poll the keyboard and have stable rasters.

Official code snippet by Atari Corp.:

ikbdvec	equ $118
; IKBD interrupt to lower its priority below the priority of the HBL
newikbd:
	move d0,-(sp)
	move sr,d0
	and #$f8ff,d0
	or #$500,d0
	move d0,sr
	move (sp)+,d0
	dc.w $4ef9
oldikbd:
	dc.l 0
	illegal

Install the new IKBD interrupt service routine to its vector at $118 and make sure to save the old vector into oldikbd.