Jump to content

Photo

Syncing Slocum's song player on NTSC and PAL


3 replies to this topic

#1 MLdB OFFLINE  

MLdB

    Star Raider

  • 71 posts
  • Location:Netherlands

Posted Wed Jun 27, 2018 4:30 AM

While converting UT2600 to PAL I noticed the awful slowdown in the music. (The beat variable that controls the playback speed of the track is updated on every nth frame, so PALs 50hz slows it down). I've come up with a fix for this, so PAL will play at the same speed as NTSC, but as I can't find anything on this issue on the forums or elsewhere, I'd like to ask if any other solutions for this already exist. If not, I will post my fix as soon as it's done.

#2 SpiceWare OFFLINE  

SpiceWare

    Draconian

  • 12,462 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Wed Jun 27, 2018 9:02 AM

I used it for the music in Medieval Mayhem. In October 2006 moderntimes99 made a revision to it to play back correct in PAL.  I don't recall specifics, can look into it later.



#3 MLdB OFFLINE  

MLdB

    Star Raider

  • Topic Starter
  • 71 posts
  • Location:Netherlands

Posted Wed Jun 27, 2018 12:29 PM

At a glance, the basic idea is the same - although I don't skip beats, only the spacing between them. And because UT2600 has 7 songs which do not all use the same tenpodelay, I needed a generic solution. I will post my completed song player code when I find some time to materialize my thoughts :)

#4 MLdB OFFLINE  

MLdB

    Star Raider

  • Topic Starter
  • 71 posts
  • Location:Netherlands

Posted Thu Jun 28, 2018 8:11 AM

Ok, here is the fix:

 

In Paul Slocum's songplayer, right below bitMaskArray, I placed

PALSyncPattern
    byte #%00000000
    byte #%00001001
    byte #%00010101
    byte #%00011011
    byte #%00011111
    byte #%00111111
    byte #%10000001
    byte #%10001001
    byte #%10010101
    byte #%10011011

These are patterns of 6 bits (bits 5..0) each and they correspond to the various TEMPODELAY options (1..10).

 

I need a single variable to keep track of the number of times tempoCount is reset (it resets every TEMPODELAY frames): PALSyncCounter

 

Slocum's tracker starts with (at the entry point):

    inc tempoCount
    lda tempoCount
    eor TEMPODELAY,X
    bne quitTempo
    sta tempoCount

The last line resets tempoCount.

 

Below this (and only for PAL) I place:

    ; Load PALSyncPattern corresponding to TEMPODELAY of this track
    lda TEMPODELAY,X
    tay
    lda PALSyncPattern-1,Y
    sta tmp_PALSyncPattern
    
    ; If bit 7 is set, we need to INC tempoCount on EVERY reset
    bpl .SkipFirstINC  
    inc tempoCount

(Note that TEMPODELAY is a table in UT2600, because I have multiple tracks. X is the offset/number of the track. In Paul's original kit TEMPODELAY is a constant.)

 

I use bit 7 of the pattern to indicate that tempoCount should be incremented EVERY time it is reset. It will then start at 1 instead of 0 and thus the next beat will come one frame earlier.

 

Then:

.SkipFirstINC
    ; PALSyncPattern is 6 bits long, corresponding to 6 resets of tempoCount
    inc PALSyncCounter
    lda PALSyncCounter
    tay
        
    ; If it's at 6, reset to 0
    eor #6
    bne .SkipResetSyncCounter
    sta PALSyncCounter

.SkipResetSyncCounter
    ; If bit N (N being PALSyncCounter) of the PALSyncPattern is set, INC tempoCount (again)
    lda tmp_PALSyncPattern
    and bitMaskArray+2,Y
    beq .SkipSecondINC
        
    inc tempoCount 

I increment PALSyncCounter to select the right bit from the pattern, use bitMaskArray (already in the songplayer) to mask off the other bits and if the result is non-zero, skip (another) tempoCount.

 

The patterns are carefully chosen to make sure PAL is keeping up pace with NTSC, albeit with some skipping, like the littlest dwarf from the Snow White animated movie trying to walk in sync with the others... As an homage to that I'll call this addition to Slocum's tracker: "The Dopey fix" :)

 

Here are PAL and NTSC for comparison:
Attached File  ut2600-pal.bin   32KB   22 downloads

Attached File  ut2600-ntsc.bin   32KB   23 downloads


Edited by MLdB, Thu Jun 28, 2018 8:15 AM.





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users