22 April 2021, 07:05 | #1 |
Registered User
Join Date: May 2019
Location: Norway
Posts: 32
|
CIA or vertical blank/copper interrupt for playing music in an intro?
Hi,
Hope that someone can point me in the right direction here :-) I'm working on a little intro here, but when it comes to playing music I just can't quite understand what's the "best practice" here. Coming from the C64 I'm used to call the music player once pr. frame. On the Amiga I beleive I can do this by trigger an interrupt with the Copper or on each Vertical Blank (music ticks 50 times/s). But I notice that quite a few of the Amiga music modules use a different speeds? In order to cope for that the CIA interrupt is used to exactly trigger the playback at the right time. That makes good sense to me, but that would mean that it's much harder to time other effects in the intro? Since the CIA interrupts would be "out of sync" in respect for the framerate I don't see how I can make effects that don't risk interfere with CIA interrupts? Or am I missing something vital here? Is it normal to use both CIA and Copper interrupts together in an intro/demo? |
22 April 2021, 08:41 | #2 |
Registered User
Join Date: Feb 2018
Location: London / UK
Posts: 112
|
Usually you use all the different interrupts. What kind of interference are you worried about?
If something needs to happen at a very specific time then you would do it using the copperlist. I don't think anyone really writes code that follows the scanlines on the Amiga when you have the copper. |
22 April 2021, 08:52 | #3 | |
Registered User
Join Date: May 2019
Location: Norway
Posts: 32
|
Quote:
Or am I missing the point here? :-) |
|
22 April 2021, 09:06 | #4 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
|
Ok, so what you can do is load any prospective music you are using into Protracker first and it will tell you once it starts playing whether its vblank or cia.
The reason for cia is for those module playing speeds that won't be played accurately by vblank because of being too slow whilst playing. The other thing you can do, is simply use PHX's playroutine, which takes care of ALL that shit for you, sets up the correct interrupt and plays all mods at the required speed. Do a search on here, or someone will point you to it, but its such a good playroutine that pretty much everyone over the past 7 (?) years just uses it. I've used in my Atari ST ports, cracktros, PHX uses it in all his games (Trap Runner series etc), and I know its used by others because its easy to implement, works in all Assemblers and is idiot proof |
22 April 2021, 09:18 | #5 | |
Registered User
Join Date: May 2019
Location: Norway
Posts: 32
|
Quote:
Ok, thanks! After a quick Google search I found this: https://aminet.net/package/mus/play/ptplayer I guess this is the PHX player you are referring to? I'll check it out! Thanks! |
|
22 April 2021, 09:33 | #6 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,409
|
Yeah, that's PHX's player
|
22 April 2021, 09:48 | #7 | |
OCS forever!
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
|
Quote:
For scenario above. Cia interrupt for music players is level6 (high priority) and usually only takes a few scan lines to execute. Because of the module timing it will generally occur at a different scan line each frame. For example on frame 1 the cia interrupt may be around scanline 10, on frame 2 it may be 30, basically it could happen anywhere. (Interesting to watch it move around with WinUAE visual debugger) If you are triggering a lev3 interrupt with the copper alongside PHX's player with cia interrupt then usually will have two outcomes: 1. Lev 6 CIA interrupt is currently executing when copper requests lev3 interrupt - Lev3 interrupt can't interrupt lev6, so lev3 interrupt only starts once lev6 interrupt finished 2. Lev 3 interrupt is currently executing, cia lev6 requested - Lev6 cia CAN interrupt lev3, once lev6 finished continues with lev3 So yes, you have to think a little bit about some scenarios where this could cause an issue. For example if you have a very precise "wait for line x" with the cpu in a lev3 then it could potentially miss that check periodically if the music player happened at the same time. So often safer to "wait for line greater than". In practice it's usually fine and you just start the music playing and forget about it |
|
22 April 2021, 10:00 | #8 |
Registered User
Join Date: Feb 2018
Location: London / UK
Posts: 112
|
a few things come to mind,
a) scrolling can be done using hardware and you generally only need to update the pointers every 16 pixels on OCS. The pointers and scroll registers in the copperlist can be updated somewhere in the vertical blank for example. The new letters in the scroller can be blit whenever at least a frame in advance outside of the visible screen. b) Generally there should be enough memory for double / triple buffers and copperlists so most things can be prepared well ahead. Rarely you need to worry about specific rasterlines. c) sync using the player variables for position or effects. |
22 April 2021, 12:00 | #9 | |
Registered User
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
|
Quote:
Easiest solution is to never use CIA timed modules Seriously, 99.99% of OCS intros and demos don't use CIA timing for playing ProTracker. If the musician knows before then it's not a problem to avoid CIA timing.. |
|
22 April 2021, 12:00 | #10 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Usually you don't have to rely on interrupts which are only valid for one specific scan line. Many raster line dependent modifications can be done by the Copper, without interrupts. Otherwise a music player running via Level-6 and lasting longer than a raster line is a problem, of course (not that I experienced that as a real problem, in the past).
(Hint: Also don't try to synchronise your program by busy-waiting for a specific raster line - which may not happen, when using a complex Level-6 interrupt routine like a player!) If you have music, which doesn't use special tempo settings, then a Level-3 VERTB-based play routine can be useful in such a scenario. In ptplayer I also decided to use Level-6 interrupts to avoid busy-waiting (e.g. to reenable Audio DMA for a new note, after the previous one has been cut). There are three strategies to make a player work without Level-6 timer interrupts:
I remember that ThePlayer 6.1 has such a VERTB-option. So it might be better suited for demo development. The main feature of ptplayer is the integration of sound effects, required by games. |
22 April 2021, 12:03 | #11 |
OCS forever!
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
|
Yes this is the thing I miss with ptplayer. Being able to have a non-cia module and run the player at a chosen time (for example, during blitter screen clear) can really help get some effects running in a frame. With cia you just have to accept the raster time tax :/
|
22 April 2021, 12:21 | #12 |
Registered User
Join Date: May 2019
Location: Norway
Posts: 32
|
Thanks everyone! Really appreciate it! Based on all your advice and tips I'll make some test cases for myself - learning by doing!
|
22 April 2021, 15:47 | #13 | |
Registered User
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
|
Quote:
I still have to remove the busy loop in PreTracker replayer and just disable dma, let the player code run, and only then busy loop if its still needed... However, perhaps we overcomplicate the rastertime optimization on Amiga. When looking on C64 there its quite common that replayers take 25-30 rasterlines and they stil have enough rastertime to usually do much nicer demos then us amiga folks |
|
22 April 2021, 18:24 | #14 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Then there is no sane way to do a VERTB-player without timer interrupts. Hmm... maybe you could do a Copper interrupt, 10 lines after VERTB? But this would make player integration more complicated as the copper list is controlled by the main program. |
|
22 April 2021, 18:50 | #15 | |
Registered User
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
|
Quote:
One benefit when you call your replayer with a Copper interrupt is that you can achieve better blitter performance. The reason is that the Blitter will get stalled when DISPLAY DMA is also active (because Blitter has lower priority). The effects gets bigger the slower your replayer is. |
|
23 April 2021, 11:48 | #16 | |
Registered User
Join Date: Jun 2020
Location: Brno
Posts: 90
|
Quote:
Code:
; 3 COPPER mode. No F20 or higher commands must be used in the song. ; - (requires a timed call to P61_Music and a timed copper command ; 11 scanlines later to set sound DMA.) |
|
23 April 2021, 13:11 | #17 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Yes. I didn't have the exact number in my mind. I just remembered that old players busy-waited for approximately 10 raster lines. Looks like P61 already offers a solution via Copper interrupt? Nice.
|
23 April 2021, 13:16 | #18 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,211
|
Is it a copper interrupt? Or is it just a write to DMACON done with the copper list? (This is how Leonards LSP player does it)
|
23 April 2021, 13:48 | #19 |
Registered User
Join Date: Jun 2020
Location: Brno
Posts: 90
|
|
23 April 2021, 17:16 | #20 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CIA periodic interrupt | jotd | Coders. Asm / Hardware | 12 | 02 January 2021 21:22 |
Extended Vertical Blank | sandruzzo | Coders. Asm / Hardware | 9 | 23 October 2019 15:17 |
Vertical blank and Bobs | geldo79 | Coders. Asm / Hardware | 4 | 21 October 2019 10:04 |
example of a CIA timer interrupt in assembler using cia.resource | Apollo | Coders. Asm / Hardware | 3 | 05 July 2013 08:40 |
CIA timer interrupt handler called twice during mod playback | absence | Coders. General | 5 | 16 March 2009 18:55 |
|
|