| |
Jammer
Registered: Nov 2002 Posts: 1335 |
Self-modifying raster interrupt for multispeeds
I'm trying to use self modyfing raster interrupt handler which increments next interrupt line by given interval - to avoid writing separate code for subsequent interrupts per single frame. How to handle $d011 oldest bit in the most efficient and proper way? |
|
| |
Mixer
Registered: Apr 2008 Posts: 452 |
I'd suggest that you use timer interrupt instead, but:
Quick and untested and unoptimised:
- Have lo and hi variables to store desired rasterline.
- Add the increment. increment must be less than 312.
- If result > $138 then substract $138. $138=312
- set next raster to d012/d011.
lda lo
clc
adc #lineaddlo
sta lo
lda hi
adc #lineaddhi
sta hi
lda lo
cmp #$38
bcc pass
lda hi
cmp #$01
bcc pass
lda lo ; substract #138
sec
sbc #$38
sta lo
lda hi
sbc #$01
sta lo
pass:
lda lo
sta $d012 ; next raster irq line lo byte
lda hi
lsr ; move lowest bit to highest bit.
ror
ora #$1b
sta $d011
|
| |
Mixer
Registered: Apr 2008 Posts: 452 |
.. and I see a bug already.
.
.
lda hi ;when substracting $138 highest byte
sbc #$01
sta hi ;!
of course. |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
Use Cia timed irq, counting cycles per frame and divide them by multispeed factor... |
| |
TheRyk
Registered: Mar 2009 Posts: 2244 |
Indeed that's how most people would do it
Here you find an overview of a few timer values
http://csdb.dk/forums/?roomid=11&topicid=58416&showallposts=1 |
| |
Jammer
Registered: Nov 2002 Posts: 1335 |
Thx, guys! :) |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
good thing with using timers is... its trivial to make it work at the correct speed on NTSC too |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
Quote: good thing with using timers is... its trivial to make it work at the correct speed on NTSC too
Indeed is just what we do in our latest music releases like:
Toca Off Alone
where speed and pitch are "adjusted" for OLD/NTSC/DREAN to play the tune just like in PAL... |