atarionline.pl How to detect end of module in RMT - Forum Atarum

Jeśli chcesz wziąć udział w dyskusjach na forum - zaloguj się. Jeżeli nie masz loginu - poproś o członkostwo.

  • :
  • :

Vanilla 1.1.4 jest produktem Lussumo. Więcej informacji: Dokumentacja, Forum.

    • 1: CommentAuthorrudla
    • CommentTime27 Feb 2014
     
    Hi,

    I have RMT module with several songs (starting at different lines).

    i can easily start any song by calling Init routine with appropriate line set in a register.

    I need to to detect, when the given song ends.

    Currently I have special line, that plays nothing and loops forever. Every song jumps at this line and this way it no longer plays anything. So my idea is detecting on which line the player currently is and when it's this loop line, it;s the end. However it seems the player does not store current line in any variable by default.

    Before I start digging in the player routine, didn't somebody already solve this problem?
    • 2: CommentAuthorwieczor
    • CommentTime27 Feb 2014 zmieniony
     
    Hi! I was struggling with this issue to achieve intro fx synchronisation with music - so certain graphics procedures were assumed to be fired at certain line of song/pattern/both (like songline 0C+pattern line 0F). Actually I didn't find line of song/pattern stored explicitely (I'm sure it's somewhere here) but I found something else - current address in the song. Because I'm lazy I realized that it's just enough for me.

    So "v_abeat" contains actual line within a pattern (typically from 00 to 3F - pattern can be shorter or longer) and its address depends on address of player routine as it's within a code.

    Current address within a song is stored in "p_song" which is stored at 211 ($D3) address - at 0 page and it's a 16-bit address of line currently played by player. It's increased by 4 with every line for 4-channell songs or by 8 for 8-channels songs (as every pattern in song list takes exactly 1 byte and they are just stored one after another ch1, ch2, ch3, ch4, ch1, ch2 ... etc. or up to ch8 for stereo songs). Initialy "p_song" is set to address of song+$D2. Just check this cause it was so for my song, but I think it works for all of them.

    Edit: to be entirely clear example yet:
    For 4 channel song loaded at address $4000 it should be:
    initialy p_song contains $40D2 - for line 00
    for next line it'll be $40D6, $40DA, $40DE etc.
    For 8 channel song p_song will go as follows: $40D2, $40DA, $40E2 etc.

    So p_song value for line XX in song is $song_address+$D2+(XX*4) or $song_address+$D2+(XX*8).
    • 3: CommentAuthorrudla
    • CommentTime27 Feb 2014
     
    Thanks for the info.
    I'm using the same technique.
    However in my case, the base address of 0 line is 2040 from the start. It seems actual address of line data is written at the module header.
    • 4: CommentAuthorbob_er
    • CommentTime28 Feb 2014
     
    In TMC player I have only pattern position (similar to v_abeat as I read). Song position I calculate manually by checking pattern position each vblank.
    This way I have pattern and song position :).
    • 5: CommentAuthorwieczor
    • CommentTime28 Feb 2014 zmieniony
     

    rudla:

    It seems actual address of line data is written at the module header.


    Good to know - I was just looking for one certain module, so in my case it was different. Now I've read specification of header and in fact there's an address. So formula will be $address_of_first_line+(XX*4) (or *8). Player keeps only address of current song line, cause calculation from line number would be pointless - it takes a lot of cpu time anyway :)