View Single Post
Old 21 December 2019, 22:20   #95
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,303
thanks for your help & detailed answer. You're probably right about the module. I made that myself very quickly and it may not run on a real amiga.

I was able to fix my code. In particular this was plain wrong:

Code:
static UWORD hardware_period(int bytes, int hertz)
{
  return ((UWORD) 100000000L / (bytes*hertz*28));
}
for the reason you explained, and also because (UWORD) 100000000L wraps to a small value, and the period always ended up being zero (when the cast isn't useful, I copied that wrongly from somewhere like Amiga Bible). fixed:
Code:
static UWORD hardware_period(int bytes, int hertz)
{
  return ((UWORD) 100000000L / (bytes*hertz*28));
}
Code:
static UWORD hardware_period(int hertz)
{
  return 100000000L / (hertz*28);
}

I'm sure I had hardcoded that at some point, and it didn't work, but there were too many things that didn't work. BTW there's a small error in your sample code (that you definitely should include in the player package). The sfx structure ends with 2 bytes, not words. It works but by luck. Fix:

Code:
sfx:	dc.l	sample
	dc.w	(sampleend-sample)/2,320,64
	dc.b	-1,1
jotd is offline  
 
Page generated in 0.04329 seconds with 11 queries