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


Forums > C64 Composing > PAL music on NTSC
2008-02-27 09:13
Mace

Registered: May 2002
Posts: 1799
PAL music on NTSC

What would be a good way to have a PAL 1-speed SID play at proper speed on an NTSC machine, when a raster-IRQ is already running?
2008-02-27 10:31
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: What would be a good way to have a PAL 1-speed SID play at proper speed on an NTSC machine, when a raster-IRQ is already running?


Use a timer... If you use a timer on CIA2 it'll even be NMI and thus run on a different vector. \o/

If it's a timing critical raster effect, then run the timer on CIA1 and thus have it generate IRQ then simply arbiter and prioritize the incoming IRQs properly in your service routine. I.e. allow a lag of the timer if the raster IRQ needs time, otherwise execute it immediately.

It's all quite simple actually.
2008-02-27 11:16
Mace

Registered: May 2002
Posts: 1799
Quote:
If it's a timing critical raster effect, then run the timer on CIA1 and thus have it generate IRQ then simply arbiter and prioritize the incoming IRQs properly in your service routine. I.e. allow a lag of the timer if the raster IRQ needs time, otherwise execute it immediately.

I understand the principle, I think... but how is it done?
How do you determine if the IRQ needs time?

And what do you mean with 'timing critical': that it's very critical in scanline location (like siderborder stuff) or just that it's using a pretty lot of rastertime?
2008-02-27 12:05
chatGPZ

Registered: Dec 2001
Posts: 11386
do your raster stuff using timers and nmi, and use a timer irq for the lower priority stuff.
2008-02-27 12:13
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: Quote:
If it's a timing critical raster effect, then run the timer on CIA1 and thus have it generate IRQ then simply arbiter and prioritize the incoming IRQs properly in your service routine. I.e. allow a lag of the timer if the raster IRQ needs time, otherwise execute it immediately.

I understand the principle, I think... but how is it done?
How do you determine if the IRQ needs time?

And what do you mean with 'timing critical': that it's very critical in scanline location (like siderborder stuff) or just that it's using a pretty lot of rastertime?


Like this: If you place the music call on a CIA2 timer and thus uses NMI the NMI will always have priority over your IRQ. That means that if your IRQ is doing some timing critical cool raster FX the NMI will interrupt it and execute the music routine and then resume the IRQ. This will effectively render your cool raster FX quite uncool.

However if you can all some slack in the music playback then simply run the music on a CIA1 timer. Then in your interrupt service routine you simply check what kind of interrupt you have and process them accordingly:

1) check $d019 for raster IRQ, if we have one then acknowledge it and do the cool raster fx, then RTI.
2) check $dc0d for timer IRQ, if we have one then acknowledge it and call the music routine, then RTI.

Since the interrupt line will be kept high until all IRQs have been acknowledged the raster IRQ will re-enter the interrupt service routine immediately if a timer IRQ have occurred meanwhile.

Now, since the scheme above FIRST checks for raster THEN checks for timer the raster will have priority and might stall the call to the music routine by the amount of time the raster routine takes to process. If this is a sideborder code opening the border for 200 lines it will most certainly stall the call to the music routine too much. But if it's a simple code like updating some sprite pointers, moving some data etc. the possible stall will be non audible.

The downside with the above is of course that if you're processing the music and during that time you get a raster IRQ then it won't be processed until the music is finished, hence directly when you have acknowledged the timer in the beginning of the IRQ then also allow more IRQs to interrupt using a simple CLI call. This will allow the possible raster interrupts to interrupt the music routine, again something that might be audible but mostly ok.


2008-02-27 12:18
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: do your raster stuff using timers and nmi, and use a timer irq for the lower priority stuff.

Yup, that is another way of doing it if you don't want to use the $d012 service of course. I've used both methods in my productions and it depends on the situation which one to choose.

F.e. not so timing critical raster code colliding with timing critical raster code is perfect to use NMI for the latter and IRQ for the first. (like sprite multiplexing vs. opening the top/bottom borders, used in Chilipower f.e.)
2008-02-27 13:48
Mace

Registered: May 2002
Posts: 1799
My 'thing' is an intro which calls several raster IRQs on various places on the screen. There's 'space' in between.

Also, in the current version I have a 4-speed music, but I need to change that to a 1-speed music.
So it seems there is enough time for playing music, just not ALL the time. There are some rasters and some less $d012-dependant stuff.

I'll try to figure out how to implement your suggestions.
It sure sounds interesting :-)

Thanks so far.
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
BOMB/ACRISE
Fred/Channel 4
master_hacker
ΛΛdZ
rexbeng
Guests online: 58
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 X-Mas Demo 2024  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Performers  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Mutetus  (9.7)
3 Jeroen Tel  (9.7)
4 Linus  (9.6)
5 Stinsen  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.068 sec.