English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Releases

 
 
Thread Tools
Old 05 June 2017, 15:39   #41
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
What does your Player do with samples of size >64kb and <=128kb when used in a protracker module?
daxb is offline  
Old 06 June 2017, 13:55   #42
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by BSzili View Post
Have you considered adding small stubs that take care of the stack/register parameters
Most C compilers support passing arguments in registers and you certainly would like to avoid the overhead passing them over the stack.

Quote:
and get the VBR and the chipset address?
I'm sure you can manage that with a small Supervisor() call and/or a assembler inline function.

BTW, this player is not OS-friendly, but for games which take over the whole system.

Quote:
Originally Posted by daxb View Post
What does your Player do with samples of size >64kb and <=128kb when used in a protracker module?
Didn't try, but I'm quite sure that it would play them. The sample lengths are already stored as words in the MOD header, which is passed unchanged to the hardware.
phx is offline  
Old 06 June 2017, 15:25   #43
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
Of course, I plan to use it in an A500 game as well. It's going to be very simple, so I prefer the C calling convention, but I get your point I'll probably just use the SDI headers to make things portable.
I looked into what can I do with Supervisor(), and this is what I came up with:

Code:
static APTR GetVBR(void)
{
	APTR vbr = NULL;
	UWORD getvbr[] = {0x4e7a, 0x0801, 0x4e73}; // MOVEC.L VBR,D0 RTE

	if (SysBase->AttnFlags & AFF_68010)
		vbr = (APTR)Supervisor((void *)getvbr);

	return vbr;
}
We'll see how it goes
BSzili is offline  
Old 08 June 2017, 00:24   #44
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by BSzili View Post
I'll probably just use the SDI headers to make things portable.
Very good. I can recommend using SDI headers.

Quote:
Code:
    UWORD getvbr[] = {0x4e7a, 0x0801, 0x4e73}; // MOVEC.L VBR,D0 RTE
I guess this might work, if you don't want to link a separate assembler source to it. Although it would be cleaner to have the getvbr-code in the code section. Most compilers will put constant data into the code section: "const UWORD getvbr[]".
phx is offline  
Old 25 June 2017, 20:36   #45
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
I finally created the C header file for the player. It works nicely with the modified function above, compiled with vasm/vbcc. For some reason .h attachments are not allowed, so I renamed it to .c.
Attached Files
File Type: c ptplayer.c (4.7 KB, 333 views)
BSzili is offline  
Old 26 June 2017, 21:12   #46
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Good work! And thanks for testing.

If you permit I would include your ptplayer.h in the next ptplayer-release.
phx is offline  
Old 27 June 2017, 04:38   #47
Shatterhand
Warhasneverbeensomuchfun
 
Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
Man it would be awesome if someone could do a lib for Blitz Basic using this ..
Shatterhand is offline  
Old 27 June 2017, 10:53   #48
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
Quote:
Originally Posted by phx View Post
Good work! And thanks for testing.

If you permit I would include your ptplayer.h in the next ptplayer-release.
Of course, that would be great! I didn't try the sfx playback yet, but I unless I messed up the registers for those functions I don't see why they wouldn't.
Speaking of sfx, since the functions expect hardware periods, maybe it would make sense to expose mt_timerval with an underscore, so there would be no need to calculated it again in the C program.

Quote:
Originally Posted by Shatterhand View Post
Man it would be awesome if someone could do a lib for Blitz Basic using this ..
I think there already is ITT:
http://eab.abime.net/showpost.php?p=970456&postcount=32
BSzili is offline  
Old 30 June 2017, 13:00   #49
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by BSzili View Post
maybe it would make sense to expose mt_timerval with an underscore, so there would be no need to calculated it again in the C program.
Could be done, although I don't want to export too many symbols.
There is also nothing to calculate. Either you take the NTSC or the PAL constant.
phx is offline  
Old 04 July 2017, 21:35   #50
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Quote:
Originally Posted by clenched View Post
This would be good substitute player for what is available for Blitz. Check out the rudimentary library here.
Unfortunately I could not get your library to work. Installing the library did work, and the keywords do tokenise, but I never get any sound out of your program.
idrougge is offline  
Old 05 July 2017, 16:51   #51
clenched
Registered User
 
Join Date: Sep 2008
Location: Gainesville U.S.A.
Posts: 771
I don't know what to tell you. It still works for me. Remember this thing as-is was never meant to be used. It was just to test the feasibility of making a Blitz library. That is why instructions to restore Blitz are provided.

Sound effects capabilities were not included. Not even as much as volume is included. Certainly none of phx's later advancements are included.

It would take someone with a good understanding of modules to make a real library and do a good job of it.

Last edited by clenched; 06 July 2017 at 17:36. Reason: typo
clenched is offline  
Old 05 July 2017, 20:17   #52
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Do you still have the source code, Clenched?
idrougge is offline  
Old 05 July 2017, 20:59   #53
clenched
Registered User
 
Join Date: Sep 2008
Location: Gainesville U.S.A.
Posts: 771
Afraid not.
clenched is offline  
Old 06 July 2017, 13:32   #54
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Never mind, I've got my own port of PHX's routine up and running. Got sound effects working this night, too. I'll upload it once the code has been cleaned up and the API is stable enough. Does anyone have any good resources on Blitz library development or source code for Blitz libs?
idrougge is offline  
Old 08 July 2017, 18:23   #55
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
There, after a few days of work I have managed to have a fairly stable, error-checked and user-friendly version of Phx's player.

What remains is optimisation, and possibly implementing the new PlayFX routine recommended by Phx instead of the old SoundFX routine (which is much easier to call!).

To install, copy ptplayer.obj to Blitzlibs:Userlibs or Blitzlibs:Otherlibs and rebuild Deflibs using either Blitzlibs:Makedeflibs or using BlitzLibMan from Aminet.
Attached Thumbnails
Click image for larger version

Name:	a4000os3-crop-1707081812-01.png
Views:	344
Size:	24.6 KB
ID:	53683  

Last edited by idrougge; 18 July 2017 at 01:19.
idrougge is offline  
Old 10 July 2017, 01:29   #56
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Question: I currently init the player with 0 as VBR, but this might not work on 68010+ machines (though it does work on my A600 with Furia EC020). How do I check if MOVEC is a valid instruction or not?
idrougge is offline  
Old 10 July 2017, 05:26   #57
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Scroll up, 3rd post on this page by BSzili.
a/b is offline  
Old 18 July 2017, 01:23   #58
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
I didn't have the luxury of using C like Bszili, and I hardly know assembly either, but by use of AttnFlags in Execbase, I've managed to identify the CPU and move the VBR if necessary. This means that the player works both on 68000 and 68040, and that MTInstall and MTRemove are no longer necessary since installation and removal of the CIA playback routine is handled automatically by the library's init/deinit routines.

New library here: http://eab.abime.net/showthread.php?...28#post1172028

Last edited by idrougge; 18 July 2017 at 01:35.
idrougge is offline  
Old 06 July 2019, 22:22   #59
clebin
Registered User
 
clebin's Avatar
 
Join Date: Apr 2012
Location: Cardiff
Posts: 405
I need a bit of help with this...

Could anyone write some sample code on how to use this in C?

I don't need the SFX stuff right now but I need to load a module from a file and play it as part of my game.
clebin is offline  
Old 07 July 2019, 21:19   #60
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Make sure you have at least ptplayer 5.1, which includes C support for BSzili. Then try something like this to load and play a MOD:
Code:
#include <exec/execbase.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <proto/exec.h>
#include <proto/dos.h>

#include "ptplayer.h"

#define CUSTOM ((void *)0xdff000)


/* compiler-specific getvbr() - FIXME! This is for vbcc. */
static void *__movecvbr(void) = "\tmovec\tvbr,d0\n\trte";

static void *getvbr(void)
{
  return __movecvbr();
}


static void play_mod(void *ptmod)
{
  void *vbr;
  UBYTE palflag;

  /* get VBR for 68010+, otherwise VBR is 0 */
  vbr = (SysBase->AttnFlags & AFF_68010) ?
        (void *)Supervisor((void *)getvbr) : NULL;

  /* CIA clock is PAL or NTSC? */
  palflag = SysBase->PowerSupplyFrequency < 59;

  /* initialize player and install Level-6 interrupt handler for CIA-B */
  mt_install_cia(CUSTOM, vbr, palflag);

  /* initialize current MOD file */
  mt_init(CUSTOM, ptmod, NULL, 0);

  /* play it for 10 seconds */
  mt_Enable = 1;
  Delay(500);

  mt_end(CUSTOM);
  mt_remove_cia(CUSTOM);
}


int main(int argc, char *argv[])
{
  struct FileInfoBlock fib;
  void *ptmod = NULL;
  int rc = 5;
  BPTR fh,lck;
  BOOL res;

  if (argc == 2) {
    /* deterimine MOD's size and allocate Chip-RAM for it */
    lck = Lock(argv[1], ACCESS_READ);
    if (!lck)
      return 1;
    res = Examine(lck, &fib);
    UnLock(lck);
    if (!res)
      return 2;
    if (!(ptmod = AllocMem(fib.fib_Size, MEMF_CHIP)))
      return 3;
    
    /* read the MOD into the buffer */
    if (!(fh = Open(argv[1], MODE_OLDFILE)))
      goto leave;
    Read(fh, ptmod, fib.fib_Size);
    Close(fh);

    /* play it */
    play_mod(ptmod);
    rc = 0;
  }

leave:
  if (ptmod)
    FreeMem(ptmod, fib.fib_Size);
  return rc;
}
Although this might work, when started from the CLI, it is not recommended to use ptplayer in an AmigaOS environment, as it accesses the hardware directly. You should take over the machine and kill the OS before using the player.

You need a piece of assembler to read the VBR register. When you don't use vbcc you have to adapt that to your compiler. Here is an example Makefile for the whole mod-test:
Code:
CC = vc +aos68k
COPT = -O1 -cpu=68010 -I. -c

AS = vasmm68k_mot
ASOPT = -Fhunk -quiet

test: test.o ptplayer.o
        $(CC) -o $@ test.o ptplayer.o

test.o: test.c
        $(CC) $(COPT) -o $@ $<

ptplayer.o: ptplayer.asm
        $(AS) $(ASOPT) -o $@ $<

clean:
        delete force quiet test test.o ptplayer.o
phx 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
MOD-player with external sound effects phx Coders. Asm / Hardware 14 18 June 2012 10:41
Amiga Forever&Protracker bad sound moriez support.WinUAE 14 06 January 2009 01:26
What was the first Amiga tracker to support external midi instruments Kola Amiga scene 3 09 December 2008 19:20
Sound/Protracker package Dunny request.Apps 3 23 July 2008 19:17
Sampled sound player? cdoty Coders. General 7 25 August 2007 16:21

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 20:05.

Top

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