Jeffry Loucks wrote:
> 
> The 68EZ328 indeed supports a mulu instruction, but you'll notice it is a
> 16x16 operation. In other words, a mulu.S. You were trying to use a mulu.L,
> which is not supported by the EC000 core.
> 
> Your original callback uses a global value to locate the multiply code
> [move.l [EMAIL PROTECTED](%a5),%a0]. It is found relative to the A5 register,
> which is reserved as the globals context register. If the A5 register is not
> correct when CallbackPeckAudio() is called, you will not be able to
> correctly locate the desired global value. In other words, the calling code
> may have it's own globals context, which could mean that the value of A5 has
> been changed to meet the calling code's needs, and is wrong for your needs.
> 
> If this is the case, you should either 1) not refer to globals in your
> callback, or 2) pass your A5 value to the callback and use SysSetA5() to
> temporarily set A5 for your use.
> 
> This is all best accomplished by creating a structure containing everything
> needed by the callback, and then passing the address of the structure to the
> callback as a userdata pointer. The structure could contain your own A5
> value, giving you full access to your normal globals, or it could contain
> everything needed without globals, or some combination.
> 
> You already do the structure bit with "struct PeckAudioType". You could
> either add your A5 value to the structure, or add a reference to the global
> in the structure. Whatever works best for you.
> 
> If you'd like info on a (32x32).L, that's another email.
> 
> Sorry so long winded.
> 

Sorry??  Your response was very helpful.  

For the sake of closure, the working code follows.

typedef struct PeckAudioType {
   SndStreamRef streamRef;
   UInt32 fileSize;
   UInt32 fileOffset;
   FileRef fileRef;
   UInt32 bufferCount;

   UInt32 s;
   UInt32 a;
   UInt32 b;

   UInt32 a5;
} PeckAudioType;

Err CallbackPeckAudio(void *pUserData, 
   SndStreamRef stream, 
   void *bufferP, 
   UInt32 frameCount) 
{
   Err err;
   UInt32 a5callback;
   PeckAudioType *pPeckAudio = (PeckAudioType *)pUserData;

   /* Read next sound stream buffer from file. */
   err = VFSFileRead(pPeckAudio->fileRef, frameCount*2, bufferP, NULL);

   a5callback = SysSetA5(pPeckAudio->a5);
   pPeckAudio->a *= pPeckAudio->b;
   SysSetA5(a5callback);

- - -

Thanks again,
Greg

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to