Simple tracked / ym / any music player on PureC/godlib

GFA, ASM, STOS, ...

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

John Atari Q
Atarian
Atarian
Posts: 3
Joined: Sun Dec 11, 2005 5:45 pm

Simple tracked / ym / any music player on PureC/godlib

Postby John Atari Q » Sun Dec 11, 2005 5:47 pm

Hi.

I'm learning some Atari coding with PureC and godlib, and was wondering could I somehow play XLR8 or some other tunes on the background, maybe even do some demoish stuff to learn...

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Simple tracked / ym / any music player on PureC/godlib

Postby Nyh » Mon Dec 12, 2005 1:45 pm

[quote="I'm learning some Atari coding with PureC and godlib, and was wondering could I somehow play XLR8 or some other tunes on the background, maybe even do some demoish stuff to learn...[/quote]
Playing music is not too hard:

Code: Select all

/*
  music player, this time in C
*/


#include <stdio.h>
#include <ext.h>
#include <tos.h>
#include <stdlib.h>

#define save_regs movem_save();reglist();
#define restore_regs movem_load();reglist();

void movem_save(void) 0x48e7;     /* movem.l reglist,-(sp) */
void movem_load(void) 0x4cdf;     /* movem.l (sp)+,reglist */
void reglist(void) 0xffff;        /* -1, alle registers */

typedef unsigned int word;
typedef unsigned char byte;

byte music[65536UL];
void (*init_music)(unsigned long song);
void (*play_music)(void);
void play_mus(void);

int main(void)
{
  Supexec((long)(play_mus));
  return 0;
}

void play_mus(void)
{
  { /* load music */
    FILE *f;
    f=fopen("m:\\muziek\\musics\\dsots_01.mus","rb");
    if(f==NULL)
    {
      printf("Source file open error!\n");
      return;
    }
    fread(music, 1, 65535UL, f);
    fclose(f);
  }
  /* init music */
  /*
    Count Zero music:
    ;Sound = Startadresse Musik
    init    =   bsr sound+0
    play    =   bsr sound+6
    quit    =   bsr sound+0
    Mad Max music:
    ;Sound = Startadresse Musik
    init    =   bsr sound+0
    play    =   bsr sound+8
    quit    =   bsr sound+0
  */
  init_music=(void*)music;
  play_music=(void*)(music+8);
  /* init music, here songnumber is three */
  save_regs;
  init_music(3L); /* init music */
  restore_regs;
  { /* play music */
    unsigned long *p=(unsigned long*)0x4ba; /* 200 Hz timer */
    unsigned long t=*p;
    do
    {
      t+=4;
      while(*p<t)
      { /* wait 20 ms */
        ;
      }
      save_regs;
      play_music(); /* play music */
      restore_regs;
    }
    while(!kbhit());
  }
  init_music(0); /* exit music */
}

This code will compile on Pure C. Normally you put the music player in the main game loop if your game is running in one vbl. Otherwise using the VBL interrupt or a timer would be a good idea.

Hans Wessels[/code]

John Atari Q
Atarian
Atarian
Posts: 3
Joined: Sun Dec 11, 2005 5:45 pm

Postby John Atari Q » Mon Dec 12, 2005 3:06 pm

Thanks :)

This "mus" format, can I create them with a tracker? And if yes, with which tracker? I also had trouble finding any mus-files for the routine, so I even cannot test it!

gwEm
Captain Atari
Captain Atari
Posts: 193
Joined: Tue Jun 08, 2004 4:43 pm
Location: London, UK
Contact:

Postby gwEm » Mon Dec 12, 2005 9:30 pm

godlib includes a SNDH play library.

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Postby Nyh » Mon Dec 12, 2005 11:08 pm

John Atari Q wrote:This "mus" format, can I create them with a tracker? And if yes, with which tracker? I also had trouble finding any mus-files for the routine, so I even cannot test it!

AFAIK .MUS files are a very common format. You can find lots of .MUS files at http://www.tphf.karoo.net/zhmain.htm. Start with the Mad Max files. Any chip music artis on the ST knows how to create them. I do not know it. I am only a stupid programmer. ;-)

Hans Wessels

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

Postby ggn » Tue Dec 13, 2005 8:28 am

Nyh wrote:
John Atari Q wrote:This "mus" format, can I create them with a tracker? And if yes, with which tracker? I also had trouble finding any mus-files for the routine, so I even cannot test it!

AFAIK .MUS files are a very common format. You can find lots of .MUS files at http://www.tphf.karoo.net/zhmain.htm. Start with the Mad Max files. Any chip music artis on the ST knows how to create them. I do not know it. I am only a stupid programmer. ;-)

Hans Wessels


We'll have to invent new words to desribe the rest of us if you proclaim yourself 'stupid' :)

George
is 73 Falcon patched atari games enough ? ^^

John Atari Q
Atarian
Atarian
Posts: 3
Joined: Sun Dec 11, 2005 5:45 pm

Postby John Atari Q » Tue Dec 13, 2005 1:12 pm

hurm, this SNDH-replay library, could somebody bust out an example how to use it. Help is greatly appriciated.. ;)

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Postby Nyh » Tue Dec 13, 2005 11:52 pm

ggn wrote:We'll have to invent new words to desribe the rest of us if you proclaim yourself 'stupid' :)

No. Just a stupid programmer. The ST scene had always lots of programmers who could do decent screens. There wehere far less designers, graphix and musix artists. See the old demo's. Most music was ripped from games or other demo's. Idem for the fonts used in the scrollers.

The TOS-crew had 5 good coders. No music or graphics artists. Most colours in my demo's are calculated, all character sets are monochrome (most of the times coloured by an algorithm). All the music was ripped.

I think there would have been lots more demo's if there were more designers grapics artist and musicians pussing the coders for new effects and finishing their work.

Hans Wessels

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

Postby ggn » Wed Dec 14, 2005 8:21 am

Nyh wrote:
ggn wrote:We'll have to invent new words to desribe the rest of us if you proclaim yourself 'stupid' :)

No. Just a stupid programmer. The ST scene had always lots of programmers who could do decent screens. There wehere far less designers, graphix and musix artists. See the old demo's. Most music was ripped from games or other demo's. Idem for the fonts used in the scrollers.

The TOS-crew had 5 good coders. No music or graphics artists. Most colours in my demo's are calculated, all character sets are monochrome (most of the times coloured by an algorithm). All the music was ripped.

I think there would have been lots more demo's if there were more designers grapics artist and musicians pussing the coders for new effects and finishing their work.

Hans Wessels


Well, it's just that most of the effects you did with Omikron Basic I would be a bit pressed to do with asm. That was what my previous comment was about :)

George
is 73 Falcon patched atari games enough ? ^^


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 3 guests