Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in 
CSDb User Forums


Forums > C64 Coding > Self-modifying raster interrupt for multispeeds
2016-03-04 15:12
Jammer

Registered: Nov 2002
Posts: 551
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?
2016-03-04 15:46
Mixer

Registered: Apr 2008
Posts: 186
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

2016-03-04 15:55
Mixer

Registered: Apr 2008
Posts: 186
.. and I see a bug already.

.           
.
lda hi         ;when substracting $138 highest byte
sbc #$01
sta hi     ;!


of course.
2016-03-04 16:21
Flavioweb

Registered: Nov 2011
Posts: 318
Use Cia timed irq, counting cycles per frame and divide them by multispeed factor...
2016-03-04 17:07
TheRyk

Registered: Mar 2009
Posts: 322
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
2016-03-04 18:03
Jammer

Registered: Nov 2002
Posts: 551
Thx, guys! :)
2016-03-04 18:12
Groepaz

Registered: Dec 2001
Posts: 7565
good thing with using timers is... its trivial to make it work at the correct speed on NTSC too
2016-03-04 20:33
Flavioweb

Registered: Nov 2011
Posts: 318
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...
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
TheRyk/MYD
Impetigo/Crescent
algorithm
Compyx/Focus
taper/ΤRIΛD
Rotteroy/Megastyle
Glenn/Shape
Guests online: 35
Top Demos
1 Uncensored  (9.7)
2 Coma Light 13  (9.7)
3 Edge of Disgrace  (9.7)
4 Comaland  (9.6)
5 Comaland 100%  (9.6)
6 Wonderland XII  (9.5)
7 Fantasmolytic  (9.5)
8 Rocketry  (9.5)
9 We Are Demo  (9.4)
10 +H2K  (9.4)
Top onefile Demos
1 Treu Love [reu]  (9.5)
2 Daah, Those Acid Pil..  (9.4)
3 Dawnfall  (9.3)
4 One-Der  (9.2)
5 Hardware Accelerated..  (9.2)
6 MD201605  (9.1)
7 Safe VSP  (9.1)
8 Goatbeard  (9.1)
9 Black Magic  (9.0)
10 Te-Te-Te-TechTech It..  (9.0)
Top Groups
1 Censor Design  (9.4)
2 Booze Design  (9.4)
3 Crest  (9.4)
4 Oxyron  (9.4)
5 Nostalgia  (9.2)
Top Original Suppliers
1 Fungus  (9.4)
2 Derbyshire Ram  (9.3)
3 hedning  (9.2)
4 Jazzcat  (9.1)
5 Irata  (9.0)

Home - Disclaimer
Copyright © No Name 2001-2016
Page generated in: 1.579 sec.