English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 15 March 2009, 23:55   #1
absence
Registered User
 
Join Date: Mar 2009
Location: moon
Posts: 373
CIA timer interrupt handler called twice during mod playback

I've been wondering why some old menu program plays a mod file with slower arpeggios than regular trackers. I started disassembling and found out that the player is the stock standard unchanged PT-Play.s from Protracker 1.1b. The difference is that the menu program calls it from a CIA timer interrupt handler instead of at vertical blank. The strange thing is that the CIA timer runs at 25 Hz instead of the regular 50 Hz. That explains the slower arpeggio, but the tune still plays at the right speed. Eventually I found out that somehow the interrupt handler is called twice each time the timer underflows (the second time immediately after the RTE from the first run). I'm curious about why this happens, as I'm trying to learn how the old Amiga hardware works. Here's the relevant code I've found so far:

Code:
init:
    ; ...
    MOVE.L #int_handler,$00000078
    MOVE.B #$7f,$00bfdd00
    MOVE.B #$6f,$00bfd500
    MOVE.B #$03,$00bfd400
    MOVE.B #$11,$00bfde00
    MOVE.B #$81,$00bfdd00
    ; ...

int_handler:
    MOVEM.L D0-D7/A0-A6,-(A7)
    MOVE.W #$2000,$00dff09c
    TST.B $00bfdd00
    BSR.W mt_music
    MOVEM.L (A7)+,D0-D7/A0-A6
    RTE.L
Is that enough to explain what goes on, or is something important missing?
absence is offline  
Old 16 March 2009, 08:21   #2
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,524
Quote:
Originally Posted by absence View Post
MOVE.W #$2000,$00dff09c
TST.B $00bfdd00
BSR.W mt_music
Paula interrupt is cleared but CIA interrupt line is still active -> Paula interrupt flag gets retriggered instantly.

(ADDED: I remember fixing this few years ago in UAE..)

Last edited by Toni Wilen; 16 March 2009 at 09:09.
Toni Wilen is offline  
Old 16 March 2009, 10:39   #3
absence
Registered User
 
Join Date: Mar 2009
Location: moon
Posts: 373
Quote:
Originally Posted by Toni Wilen View Post
Paula interrupt is cleared but CIA interrupt line is still active -> Paula interrupt flag gets retriggered instantly.
Ahh, I see! But why does it only retrigger once instead of continously?

Also, what code would have to be added to the interrupt handler to avoid the retrigging?
absence is offline  
Old 16 March 2009, 10:43   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,524
Quote:
Originally Posted by absence View Post
Ahh, I see! But why does it only retrigger once instead of continously?
Because tst.b $bfdd00 clears the CIA interrupt

Quote:
Also, what code would have to be added to the interrupt handler to avoid the retrigging?
Clear CIA interrupts before writing to INTREQ.
Toni Wilen is offline  
Old 16 March 2009, 11:48   #5
absence
Registered User
 
Join Date: Mar 2009
Location: moon
Posts: 373
Quote:
Originally Posted by Toni Wilen View Post
Clear CIA interrupts before writing to INTREQ.
Doh! I thought I had already tried swapping the MOVE and TST, but I must have goofed up the debugger commands, because it didn't work the last time. When I tried again now, it nicely slowed down to 25 Hz. Thanks for solving the mystery!

I can't help wondering whether the effect was intended, or if the coder couldn't figure out why the music played twice as fast and simply solved it by reducing the CIA frequency.
absence is offline  
Old 16 March 2009, 18:55   #6
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,524
Quote:
Originally Posted by absence View Post
I can't help wondering whether the effect was intended, or if the coder couldn't figure out why the music played twice as fast and simply solved it by reducing the CIA frequency.
I vote "couldn't figure out" guess
Toni Wilen is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
example of a CIA timer interrupt in assembler using cia.resource Apollo Coders. Asm / Hardware 3 05 July 2013 08:40
[WinUAE/A500] CIA A - Timer A INT2 problem leoha Coders. Asm / Hardware 2 22 October 2012 10:18
Wanted: mod i think was called echoes or silence? Impakt request.Modules 11 28 April 2009 00:17
Looking for a mod called galaxy kolorabi request.Modules 3 31 May 2005 01:20
Whats this Music mod called? WOC_Admin request.Modules 0 18 May 2003 18:50

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 00:42.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.06871 seconds with 13 queries