THK music file

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

rockyone
Captain Atari
Captain Atari
Posts: 427
Joined: Thu Jan 20, 2011 8:47 pm
Location: France
Contact:

THK music file

Postby rockyone » Fri Jul 13, 2018 7:01 pm

In high resolution, the pace is faster
How to change it?

User avatar
Showaddywaddy
Atari Super Hero
Atari Super Hero
Posts: 670
Joined: Thu Jun 06, 2002 12:01 pm
Location: Montreal, Quebec
Contact:

Re: THK music file

Postby Showaddywaddy » Fri Jul 13, 2018 10:49 pm

The megatizer tune will be running on the vertical blank.

You need to use the MFP instead.

rockyone
Captain Atari
Captain Atari
Posts: 427
Joined: Thu Jan 20, 2011 8:47 pm
Location: France
Contact:

Re: THK music file

Postby rockyone » Fri Jul 13, 2018 11:53 pm

Showaddywaddy wrote:The megatizer tune will be running on the vertical blank. .

ok but I thought it was possible to edit for high resolution

Showaddywaddy wrote:You need to use the MFP instead.

With the MFP, I do not know how to do it!

User avatar
ggn
Atari God
Atari God
Posts: 1202
Joined: Sat Dec 28, 2002 4:49 pm

Re: THK music file

Postby ggn » Sat Jul 14, 2018 8:28 am

rockyone wrote:With the MFP, I do not know how to do it!


Here's a small snippet that illustrates how to do it:

Code: Select all

;
; setup music
;
                move    SR,-(SP)
                move    #$2700,SR
                move.l  $0114.w,oldtimer
                move.l  $0114.w,zakjump+2
                move.l  #zaktimer,$0114.w
                moveq   #1,D0   ;setup music player here if needed
                jsr     music     
                move    (SP)+,SR

...
...
...

musicfreq       EQU 50

zaktimer:       subi.w  #musicfreq,tic
                bgt.s   zakjump
                addi.w  #200,tic

                movem.l D0-A6,-(SP)
                move    SR,-(SP)
                move    #$2300,SR
                jsr     music+8   ;jump to music VBL routine
                move    (SP)+,SR
                movem.l (SP)+,D0-A6
zakjump:        move.l  #'T_C!',-(SP)
                rts

tic:            DC.W 200
oldtimer      ds.l 1


Just change 'musicfreq' to the tune's frequency and you're good to go
is 73 Falcon patched atari games enough ? ^^

rockyone
Captain Atari
Captain Atari
Posts: 427
Joined: Thu Jan 20, 2011 8:47 pm
Location: France
Contact:

Re: THK music file

Postby rockyone » Wed Jul 18, 2018 12:25 pm

Hello GGn
I did not understand everything, and of course I could not use it.

move.l $0114.w,zakjump+2 , written on 'T_C!' ?
moveq #1, D0 , configuration of the music player here if necessary ????

zakjump: move.l #'T_C!',-(SP) Why do you put it on the pile ?


Currently, I always use this code which does not work with the good rhythm in high resolution ...

Code: Select all

;   call ziq( L musique, W op% )

      movem.l  d0-d7/a0-a6,-(sp)
      move.l  64(sp),a3
     
      tst.w  68(sp)      ; 1  on / 0  off
      beq.s  music_on

music_off:   
      addq.l  #4,a3
      move.l  #0,$4d2
      bsr.s   supexec
      bra.s   end_      

music_on:   
      bsr.s   supexec
      addq.l  #8,a3
      move.l  a3,$4d2       ;Vbl #2
end_   
      movem.l  (sp)+,d0-d7/a0-a6
      rts

supexec:
      move.l  a3,-(sp)
      move.w  #$26,-(sp)
      trap  #14
      addq.l  #6,sp
      rts
      
      end

User avatar
ggn
Atari God
Atari God
Posts: 1202
Joined: Sat Dec 28, 2002 4:49 pm

Re: THK music file

Postby ggn » Wed Jul 18, 2018 9:22 pm

rockyone wrote:Hello GGn
I did not understand everything, and of course I could not use it.


Okay, let me clarify things for you then

rockyone wrote:move.l $0114.w,zakjump+2 , written on 'T_C!' ?
zakjump: move.l #'T_C!',-(SP) Why do you put it on the pile ?


Yes, this is a bit of self modifying code. You should run the code at the top (setup music) at the beginning of your program. This will set up timer C (which runs at 200Hz) to call the music player. Now, the system depends quite a bit on timer C: GEM itself uses it to count time, and disk drivers also use it. So if your code wants to play nice to the system it's always a good idea to call the system timer C code. If this was a fixed address I could just write
or whatever the supposed address of the timer C code was. But I don't, so I need to determine that at runtime. "T_C!" is just a placeholder value - after the "move.l $114.w,zakjump+2" it will be loaded with the proper address. So once the music player is over, it will call the system timer C. I could have done this using a cleaner method, like storing $114 to a variable and then loading it during timer C execution, but this wastes cycles and I usually want low latency. So there you go. Sorry for the confusion.

rockyone wrote:moveq #1, D0 , configuration of the music player here if necessary ????


I don't know if or how your music player wants to set up for playing the tune. The code

Code: Select all

                moveq   #1,D0   ;setup music player here if needed
                jsr     music     

is standard init code for any tune from the SNDH archive.

rockyone wrote:Currently, I always use this code which does not work with the good rhythm in high resolution ...

Code: Select all

;   call ziq( L musique, W op% )

      movem.l  d0-d7/a0-a6,-(sp)
      move.l  64(sp),a3
     
      tst.w  68(sp)      ; 1  on / 0  off
      beq.s  music_on

music_off:   
      addq.l  #4,a3
      move.l  #0,$4d2
      bsr.s   supexec
      bra.s   end_      

music_on:   
      bsr.s   supexec
      addq.l  #8,a3
      move.l  a3,$4d2       ;Vbl #2
end_   
      movem.l  (sp)+,d0-d7/a0-a6
      rts

supexec:
      move.l  a3,-(sp)
      move.w  #$26,-(sp)
      trap  #14
      addq.l  #6,sp
      rts
      
      end


This will play the tune at 71Hz on mono monitors.From what I can see that code simply gets passed the music address and a command to switch the music on or off. So I guess if you were to use my code you would need to do something like

Code: Select all

;
; setup music
;
setup_music:
                move.l 8(sp),zakvbl+2
                move    SR,-(SP)
                move    #$2700,SR
                move.l  $0114.w,oldtimer
                move.l  $0114.w,zakjump+2
                move.l  #zaktimer,$0114.w
                move    (SP)+,SR
                rts
               
musicfreq       EQU 50

zaktimer:       subi.w  #musicfreq,tic
                bgt.s   zakjump
                addi.w  #200,tic

                movem.l D0-A6,-(SP)
                move    SR,-(SP)
                move    #$2300,SR
zakvbl:                jsr     music+8   ;jump to music VBL routine
                move    (SP)+,SR
                movem.l (SP)+,D0-A6
zakjump:        move.l  #'T_C!',-(SP)
                rts

tic:            DC.W 200
oldtimer      ds.l 1


or something like that - I'm typing this without testing so I'm not sure the 8(sp) is correct there.

Hope this helps!
is 73 Falcon patched atari games enough ? ^^

rockyone
Captain Atari
Captain Atari
Posts: 427
Joined: Thu Jan 20, 2011 8:47 pm
Location: France
Contact:

Re: THK music file

Postby rockyone » Wed Jul 18, 2018 10:23 pm

Thank you for the explanations.
It's very interesting this way of modifying the code ... :D


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 2 guests