You can respond to changes in $d012 using the IRQ raster handler. I will lay out a couple of features from my game code, because it can be hairy to make it work if you use the wrong combination of spells. It should also give you enough material for Google.
In particular, you may need to set your int handler to $0314 , as well as mention the code, in which case your IRQ handler will be bound using its own default handlers, and you need to skip the pha ... pha bit at the beginning of your handler. This can be useful if you need to use some of its input / output code.
;;; ----------------------------------------------------------------------------- ;;; install raster interrupt handler ;;; ----------------------------------------------------------------------------- sei ; turn off interrupts ldx
Then you process these interrupts as follows:
;;; ----------------------------------------------------------------------------- ;;; raster IRQ handler ;;; ----------------------------------------------------------------------------- int_handler pha ; needed if our raster int handler is set in fffe instead of 0314 txa pha tya pha ; ... do your stuff here ...
eriksensei
source share