Welcome, Guest. Please login or register.

Author Topic: Catagon  (Read 7163 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Leffmann

  • Full Member
  • ***
  • Join Date: Feb 2011
  • Posts: 119
    • Show all replies
Re: Catagon
« on: September 23, 2014, 02:29:14 PM »
Quote from: BSzili;773469
It turns out that all the problems (jerkiness, attached sprites falling apart, etc) were caused by ptreplay.library. It pains me, but I had to disable the music for the time being. If anyone knows any other solution to play ProTracker music, I'm all ears.


It's difficult to say what the cause is, but it sounds like the ptreplay.library is eating up too much CPU time. Have you tried The Player 6.1? It's very time-efficient, and it performs some compression on the module to save a bit of RAM as well.
 

Offline Leffmann

  • Full Member
  • ***
  • Join Date: Feb 2011
  • Posts: 119
    • Show all replies
Re: Catagon
« Reply #1 on: September 23, 2014, 07:42:06 PM »
Quote from: BSzili;773745
The player interrupt definitely uses up too much CPU time. A better protracker replayer would solve the problem too, but they are all written in assembler, so it takes some effort to glue them to C code.


If you're writing it in C then it's just a few lines of code to fix that actually. Let me write up an example.

EDIT:

https://dl.dropboxusercontent.com/u/8177628/p61.zip

Just link with p61.o and use it f.ex. like this:
Code: [Select]
#include <proto/dos.h>

extern char module[];
extern char samples[];
extern int P61_Init(void*, void*);
extern void P61_End();

int main()
{
  if (P61_Init(module, samples) == 0)
  {
    Delay(10*50);
    P61_End();
  }

  return 0;
}
« Last Edit: September 23, 2014, 07:59:56 PM by Leffmann »
 

Offline Leffmann

  • Full Member
  • ***
  • Join Date: Feb 2011
  • Posts: 119
    • Show all replies
Re: Catagon
« Reply #2 on: September 25, 2014, 03:26:20 PM »
I added a stub to the player for standard C calls. IMO it's cleaner and more elegant than using compiler-specific keywords for register usage. It works and plays songs exactly like it's supposed to, it's not some random guesswork.

I'm not sure what the optimizations in the unofficial 6.1.11 are, as the official 6.1 is pretty fast and optimized as it is. I tried 6.1.8 some time ago, but the changes made it confusing to use, and it didn't work reliably. The problems might be fixed in 6.1.11, but I haven't tried it.
 

Offline Leffmann

  • Full Member
  • ***
  • Join Date: Feb 2011
  • Posts: 119
    • Show all replies
Re: Catagon
« Reply #3 on: September 26, 2014, 06:35:09 PM »
The arguments go on the stack in reverse order, D0/D1/A0/A1 can be used as scratch registers, all other registers must be preserved, and any return value should be passed in D0, so the stubs look like this:
Code: [Select]
_P61_Init  movem.l  (4, sp), a0-a1
           movem.l  d2-d7/a2-a6, -(sp)
           moveq    #0, d0
           bsr      P61_Init
           movem.l  (sp)+, d2-d7/a2-a6
           rts

P61_Init   ...


_P61_End   movem.l  a3/a6, -(sp)
           lea      $dff000, a6
           bsr      P61_End
           movem.l  (sp)+, a3/a6
           rts

P61_End    ...