English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 13 January 2018, 00:54   #1
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Playing a protracker module?

I've been trying for the last couple of hours to get a Protracker module (from Zool - mod.sweetiesomething) to play.

The player source I'm using is this one which looks useful - https://grml.de/aminet/mus/play/ptplayer.readme

It's worth pointing out the target system is an A500. I'm copying the module into chip ram.

Can anyone point me at a good example of how to initialize and play the a module using this player, some of the read me is ambiguous and I'm struggling to get it working (basically I can't get it to play anything).

Here's my latest incarnation of it....

Code:
 	move.w	#%1000001111001111,DMACON(a6) ; Enable BPL and COP

	lea	CHIPBASE,a6
	lea	CHIP_MOD_INGAME,a0
	lea	$80010,a1
	clr.l	(a1)
	moveq	#0,d0
	jsr	_mt_init

	move.b	#-1,mt_Enable		; Play music

	lea	CHIPBASE,a6		; hw base
	sub.l	a0,a0			; ?????/
	moveq	#1,d0			; pal
	jsr	_mt_install_cia
	
	
	lea	CHIPBASE,a6
	moveq	#60,d0
	jsr	_mt_mastervol
; ------ MUSIC ------

Any help really is appreciated!!!!

Geezer
mcgeezer is offline  
Old 13 January 2018, 12:07   #2
WayneK
Registered User
 
Join Date: May 2004
Location: Somewhere secret
Age: 50
Posts: 365
I used this replayer in a trainermenu (because it has awesome sound fx support), a quick look at the source shows this:-

Code:
;init musicplayer
;a0 is already VBR
  moveq #1,d0   ;PAL
  jsr mt_install_cia

  lea musicdata,a0    ;ptr to mod
  moveq #0,d0     ;start from pos #0
  movea.l d0,a1   ;a1=NULL, samples in mod
  jsr mt_init
;CIA irq installed, music ready but not started
Then when I need the music to play:-

Code:
;start music
  st  mt_Enable
..and finally when I need it to end/shutdown

Code:
;stop music player
  jsr mt_end
;and remove CIA
  jsr mt_remove_cia
The reason for the "sub.l a0,a0" you were puzzled about is A0 is the VBR pointer coming into the CIA install, which = 0 if you're on OCS/68000.

Hope this is some use, looking forward to seeing/hearing your Bomb Jack version soon
WayneK is offline  
Old 13 January 2018, 12:27   #3
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Had a quick look too, that's basically all that's needed to play a module:

Code:
	lea	$dff000,a6
	moveq	#1,d0		; PAL
	bsr	_mt_install_cia		; a0 must point to VBR (startup code handles this for me)

	lea	_mt_data,a0
	sub.l	a1,a1
	moveq	#0,d0
	bsr	_mt_init

	st	_mt_Enable

LOOP	btst	#6,$bfe001
	bne.b	LOOP


	bsr	_mt_end
	bsr	_mt_remove_cia
	rts
StingRay is offline  
Old 13 January 2018, 13:16   #4
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Thank you very much gents, I'll give this a go right now.

Cheers,
Geezer
mcgeezer is offline  
Old 13 January 2018, 13:27   #5
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
It looks like I wasn't doing much wrong initializing the music. I still can't get it to actually play though. I know the module is good because the Action Replay tracker command finds and plays it at $80000 no problem.

What on earth am I doing wrong, have a feeling this is in the startup code but I can't see it. Can you guys spot anything obvious?

Code:
jmp	START
    
    include custom.i
    include cia.i
    include ptplayer.s
    
    even


CHIP_MOD:	equ	$80000

START:
	lea	CHIP_MOD,a0
	lea	CHIP_MOD_INGAME,a1
	lea	CHIP_MOD_END,a2
	move.l	a2,d7
	sub.l	a1,d7
	lsr.l	#2,d7
.loop:	move.l	(a1)+,(a0)+
	dbf	d7,.loop

	lea	CHIPBASE,a6
	move.w	$2(a6),OLD_DMA

	move.w	#$7ff,$96(a6)
	move.w	#%1000001111000000,$96(a6)
	move.w	$1c(a6),OLD_IRQ
	move.w	#$7fff,$9a(a6)
	move.w	#$e000,$9a(a6)

	lea	CHIPBASE,a6		; hw base
	sub.l	a0,a0			; ?????/
	moveq	#1,d0			; pal
	jsr	_mt_install_cia

	lea	CHIPBASE,a6
	lea	CHIP_MOD,a0
	sub.l	a1,a1
	moveq	#0,d0
	jsr	_mt_init


	st	mt_Enable

mouse:	btst	#6,$bfe001
	bne.s	mouse
		
	clr.b	_mt_Enable

	lea	CHIPBASE,a6
	jsr	_mt_end

	lea	CHIPBASE,a6
	jsr	_mt_remove_cia

	lea	CHIPBASE,a6
	move.w	#$7fff,$9a(a6)
	move.w	#$7ff,$96(a6)
	
	moveq	#0,d7
	move.w	OLD_IRQ,d7
	or.w	#$8000,d7
	move.w	d7,$9a(a6)

	move.w	OLD_DMA,d7
	or.w	#$8000,d7
	move.w	d7,$96(a6)

	moveq	#0,d0
	rts
	
OLD_DMA:	dc.w	0
OLD_IRQ:	dc.w	0

CHIP_MOD_INGAME:	incbin	"mod.sweetielandfunk"
			even
CHIP_MOD_END:
mcgeezer is offline  
Old 13 January 2018, 13:31   #6
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Code looks fine at first glance. The only thing I see is that you enable level 6 interrupts, are you initialising the level 6 vector before? And for using the replayer this is not needed as it handles interrupts on its own. Also, what about the VBR? Is it definitely at $0.w?
StingRay is offline  
Old 13 January 2018, 13:46   #7
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Quote:
Originally Posted by StingRay View Post
Code looks fine at first glance. The only thing I see is that you enable level 6 interrupts, are you initialising the level 6 vector before? And for using the replayer this is not needed as it handles interrupts on its own. Also, what about the VBR? Is it definitely at $0.w?
Apologies StingRay I'm still getting to grips with the Amiga hardware and it's a long time since I dealt with the Interrupts - I have the HRM to hand though.

From what I understand the Level 6 interrupt vector address is at address $78, that's the only reason I worked out that the routine needed A1 setting to $0 and I'm unsure of where I would resolve that address (VBR?) on other Amiga's, I'm on an A500 configuration here though.

I suspect the problem is what you first picked up on around initializing the level 6 vector, I'm not entirely sure what you mean by doing that. Would you be able to explain a little further please or point me to the right place in the HRM so I can fully understand?

Really appreciate your support on this guys.
mcgeezer is offline  
Old 13 January 2018, 13:53   #8
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
$78.w is indeed the level 6 interrupt vector. This is only valid for 68000 though as there is no VBR. For all other 68k CPU's the interrupt vectors are relative to the VBR which can be anywhere so you would need to get the VBR ptr and then initialise the level 6 vector using the VBR as offset (e.g. move.l OldVBR(pc),a0 pea NewLev6(pc) move.l (a7)+,$78(a0)).

And this needs to be done before you enable the level 6 interrupts in your code for obvious reasons.

For now I still suspect the VBR is the culprit though as I can't see any other possible reasons for the module not playing. Except maybe that it gets corrupted when copying it to $80000 but you said it can be found and played correctly in memory which leaves the VBR as the only possible reason.
StingRay is offline  
Old 13 January 2018, 14:47   #9
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by mcgeezer View Post
What on earth am I doing wrong, have a feeling this is in the startup code but I can't see it. Can you guys spot anything obvious?
Yes. I admit, I had to look about 15 minutes to spot it, but you have a small typo in your source: mt_Enable should be _mt_Enable!

Unfortunately there was no error from the assembler for this line, becaused you included the ptplayer source, which indeed defines mt_Enable, as structure offset $1c6.

BTW, you might want to use a linker to separate your sources.
phx is offline  
Old 13 January 2018, 14:55   #10
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by phx View Post
Yes. I admit, I had to look about 15 minutes to spot it, but you have a small typo in your source: mt_Enable should be _mt_Enable!
Nice one!
StingRay is offline  
Old 13 January 2018, 16:55   #11
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Quote:
Originally Posted by phx View Post
Yes. I admit, I had to look about 15 minutes to spot it, but you have a small typo in your source: mt_Enable should be _mt_Enable!

Unfortunately there was no error from the assembler for this line, becaused you included the ptplayer source, which indeed defines mt_Enable, as structure offset $1c6.

BTW, you might want to use a linker to separate your sources.
Ugghhh... this has had me scratching my head for hours...

Thankyou ever so much for saving my sanity.

Thanks for the tip also on separating the source, I do have them all separated in my main Bomb Jack project... this was just a debugging excercise to find out why I couldn't get music to play.

mcgeezer is offline  
Old 05 May 2018, 14:48   #12
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Sorry if I retake this post, I'm trying to use this library to play a simple module.

Code is this:

Code:

	SECTION	modplay,CODE

	lea	mt_data,a0
	moveq	#0,d0
	bsr	_mt_init

	st	_mt_Enable

LOOP	btst	#6,$bfe001
	bne.b	LOOP


	bsr	_mt_end
	bsr	_mt_remove_cia
	rts

	incdir  "dh1:own/ptplayer/"
	include	"ptplayer.s"	

mt_data:
	incdir  "dh1:own/mod/"
	incbin	"mod.purple-shades"

	end
However I can't hear any sound.

My system is Amiga 600 1MB, I'm using AsmOne 1.02.

Can you give me some hints?
Thank you

Last edited by fstarred; 05 May 2018 at 18:16.
fstarred is offline  
Old 05 May 2018, 15:59   #13
Apollo
Registered User
 
Apollo's Avatar
 
Join Date: Sep 2008
Location: Germany
Age: 49
Posts: 137
quick shot:
Judging from your "SECTION" statement this section could be located in fastmem (if your machine has fastmem). Since the module at "mt_data" is then at fastmem too you won't here any samples.

Put the module in a chipmem section f.ex. with "SECTION data,DATA_C" and see if this makes a difference.
Apollo is offline  
Old 05 May 2018, 18:24   #14
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Apollo's annotation is valid, but there is so much more missing.

Did you establish an interrupt routine, which plays the music? Is the source complete? Then I don't see anything. Usually Protracker mods are played using the CIA-B timer interrupt. You should install that first.

Code:
        lea     $dff000,a6
        sub.l   a0,a0
        moveq   #1,d0
        bsr     _mt_install_cia
This will patch the level 6 interrupt vector and install the player interrupt. Assuming VBR is at $000000 (a0=0) and you are running on a PAL system (d0=1). But you should really try to determine these parameters from your host system.

When you exit your program you shouldn't not forget to restore the original interrupt vector with
Code:
        lea     $dff000,a6
        bsr     _mt_remove_cia
Then you may call _mt_init to set a module to play, like you did. But you forgot to pass the custom-chip base address in A6. Please refer to the documentation in the header of the player source:
Code:
; _mt_init(a6=CUSTOM, a0=TrackerModule, a1=Samples|NULL, d0=InitialSongPos.b)
Also do not forget to initialize A1 with 0, when you don't have samples separated from the tracker data (which is the normal case).

_mt_end again needs A6=$dff000. You're lucky it didn't crash your system.
phx is offline  
Old 07 May 2018, 09:25   #15
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Sorry if I still miss some points..

this is my code now:

Code:
	SECTION	mod_play,CODE

	lea     $dff000, a6 ; custom address
	sub.l   a0, a0
	moveq   #1, d0	; _mt_install_cia(a6=CUSTOM, a0=AutoVecBase, d0=PALflag.b)
	bsr     _mt_install_cia 
	
	lea	mt_data,a0
	moveq	#0,d0	; _mt_init(a6=CUSTOM, a0=TrackerModule, a1=Samples|NULL, d0=InitialSongPos.b)
	bsr	_mt_init 

	st	_mt_Enable

LOOP	btst	#6,$bfe001
	bne.b	LOOP

	bsr	_mt_end
	
	lea	custom, a6
	bsr	_mt_remove_cia
	rts

	incdir  "dh1:own/ptplayer/"
	include	"ptplayer.s"

	SECTION	music_data, _C
	
mt_data:
	incdir  "dh1:own/mod/"
	incbin	"mod.purple-shades"

	end

The code faults on mt_init .

What I still don't get:

1. sub.l a0, a0 ; what does mean substracting an address with itself ?
2. a1=Samples|NULL ; Also do not forget to initialize A1 with 0

How to init A1 with 0? something like this
move $0, a1
or
move $0, (a1)

Hovever I tried both but system did crash or doesn't work as you predicted

Thank you in advance

Last edited by fstarred; 07 May 2018 at 09:37.
fstarred is offline  
Old 07 May 2018, 09:58   #16
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by fstarred View Post
The code faults on mt_init .
Of course it does because you didn't listen to PHX.

Quote:
Originally Posted by fstarred View Post
What I still don't get:

1. sub.l a0, a0 ; what does mean substracting an address with itself ?
It clears the address register (a0 in this case).


Quote:
Originally Posted by fstarred View Post
2. a1=Samples|NULL ; Also do not forget to initialize A1 with 0

How to init A1 with 0? something like this
move $0, a1
or
move $0, (a1)
That's both wrong! If you check my answer to your first question you may find the solution yourself.

Last edited by StingRay; 07 May 2018 at 10:57. Reason: Quoting corrected.
StingRay 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
How can translate David Whittaker module to protracker Thyphoon request.Modules 35 30 January 2021 10:55
Playing module makes shapes to flicker Shatterhand Coders. Blitz Basic 34 07 February 2017 08:22
HippoPlayer very slow down system when playing module michaljarz support.WinUAE 6 21 February 2016 20:34
Protracker v1.3b Strages support.Apps 4 08 December 2013 19:59
ProTracker Module Compression h0ffman support.Other 12 24 September 2010 19:57

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 17:36.

Top

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