Jump to content
IGNORED

Syncing Slocum's song player on NTSC and PAL


MLdB

Recommended Posts

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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:
ut2600-pal.bin

ut2600-ntsc.bin

Edited by MLdB
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...