parse_abi.c 9.61 KB

/*
 * Interpret ABI command list and display it
 *
 */

#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#ifdef __sgi__
#include <os.h>
#include <ultra64.h>
#endif
#include <gu.h>
#ifdef __sgi__
#include <bstring.h>
#endif
#include <libaudio.h>
#include "dlprint.h"

void ParseAbiCL(u8 *data, u32 nbytes)
{
    Acmd   *cmd = (Acmd *)data;
    Acmd   *endCmd = cmd + (nbytes/sizeof(Acmd));
    float  temp;

    PRINTF("----------------------------------------------------\n");
    PRINTF("Parsing audio command list\n\n");
    for (; cmd < endCmd; cmd++) {
            
        switch (cmd->adpcm.cmd) {
          case A_SPNOOP:
              PRINTF("A_SPNOOP: %d\n", cmd->adpcm.cmd);
              PRINTF("\n");
              break;
                
          case A_ADPCM:
              PRINTF("A_ADPCM: %d\n", cmd->adpcm.cmd);
              PRINTF("\tflags: 0x%x\n", cmd->adpcm.flags);
              PRINTF("\tgain: 0x%x\n", cmd->adpcm.gain);
              PRINTF("\tsegment: %d\n", cmd->adpcm.addr>>26);
              PRINTF("\tstate offset: 0x%x\n", cmd->adpcm.addr & 0x03ffffff);
              PRINTF("\n");
              break;
                
          case A_CLEARBUFF:
              PRINTF("A_CLEARBUFF: %d\n", cmd->adpcm.cmd);
              PRINTF("\tpad1: 0x%x\n", cmd->clearbuff.pad1);
              PRINTF("\tdmem: 0x%x\n", cmd->clearbuff.dmem);
              PRINTF("\tpad2: 0x%x\n", cmd->clearbuff.pad2);
              PRINTF("\tcount: 0x%x, %d\n", cmd->clearbuff.count,
                     cmd->clearbuff.count);
              PRINTF("\n");
              break;
                
          case A_ENVMIXER:
              PRINTF("A_ENVMIXER: %d\n", cmd->adpcm.cmd);
              PRINTF("\tflags: 0x%x\n", cmd->envelope.flags);
              PRINTF("\tpad1: 0x%x\n", cmd->envelope.pad1);
              PRINTF("\tstate offset: 0x%x\n", cmd->envelope.addr);
              PRINTF("\n");
              break;
                
          case A_LOADBUFF:
              PRINTF("A_LOADBUFF: %d\n", cmd->adpcm.cmd);
              PRINTF("\tpad1: 0x%x\n", cmd->loadbuff.pad1);
              PRINTF("\tsegment: %d\n", cmd->loadbuff.addr>>26);
              PRINTF("\tdram offset: 0x%x\n", cmd->loadbuff.addr & 0x03ffffff);
              PRINTF("\n");
              break;
                
          case A_RESAMPLE:
              PRINTF("A_RESAMPLE: %d\n", cmd->adpcm.cmd);
              PRINTF("\tflags: 0x%x\n", cmd->resample.flags);
              PRINTF("\tpitch: 0x%x, %f\n", cmd->resample.pitch,
                     (float)cmd->resample.pitch/(float)0x8000);
              PRINTF("\tsegment: %d\n", cmd->resample.addr>>26);
              PRINTF("\tstate offset: 0x%x\n",
                     cmd->resample.addr & 0x03ffffff);
              PRINTF("\n");
              break;
                
          case A_SAVEBUFF:
              PRINTF("A_SAVEBUFF: %d\n", cmd->adpcm.cmd);
              PRINTF("\tpad1: 0x%x\n", cmd->savebuff.pad1);
              PRINTF("\tsegment: %d\n", cmd->savebuff.addr>>26);
              PRINTF("\tdram offset: 0x%x\n", cmd->savebuff.addr & 0x03ffffff);
              PRINTF("\n");
              break;
                
          case A_SEGMENT:
              PRINTF("A_SEGMENT: %d\n", cmd->adpcm.cmd);
              PRINTF("\tpad1: 0x%x\n", cmd->segment.pad1);
              PRINTF("\tpad2: 0x%x\n", cmd->segment.pad2);
              PRINTF("\tnumber: 0x%x\n", cmd->segment.number);
              PRINTF("\tbase: 0x%x\n", cmd->segment.base);
              PRINTF("\n");
              break;
                
          case A_SETBUFF:
              if (cmd->setbuff.flags & A_AUX) {
                  PRINTF("A_SETBUFF: %d\n", cmd->adpcm.cmd);
                  PRINTF("\tflags: 0x%x = %s\n", cmd->setbuff.flags, "A_AUX");
                  PRINTF("\tdmoutR: 0x%x\n", cmd->setbuff.dmemin);
                  PRINTF("\tdmauxL: 0x%x\n", cmd->setbuff.dmemout);
                  PRINTF("\tdmauxR: 0x%x\n", cmd->setbuff.count);
                  PRINTF("\n");
              }
              else {
                  PRINTF("A_SETBUFF: %d\n", cmd->adpcm.cmd);
                  PRINTF("\tflags: 0x%x\n", cmd->setbuff.flags);
                  PRINTF("\tdmemin: 0x%x\n", cmd->setbuff.dmemin);
                  PRINTF("\tdmemout: 0x%x\n", cmd->setbuff.dmemout);
                  PRINTF("\tcount: 0x%x, %d\n", cmd->setbuff.count,
                         cmd->setbuff.count);
                  PRINTF("\n");
                  break;
              }
              break;
                
          case A_SETVOL:
              if (cmd->setvol.flags & A_AUX) {
                  PRINTF("A_SETVOL: %d\n", cmd->adpcm.cmd);
                  PRINTF("\tflags: 0x%x = %s\n", cmd->setvol.flags, "A_AUX");
                  PRINTF("\tdry amount: 0x%x\n", cmd->setvol.vol);
                  PRINTF("\tunused: 0x%x\n", cmd->setvol.voltgt);
                  PRINTF("\twet amount: 0x%x\n", cmd->setvol.volrate);
                  PRINTF("\n");
              }
              else if (cmd->setvol.flags & A_VOL) {
                  if (cmd->setvol.flags & A_LEFT) {
                      PRINTF("A_SETVOL: %d\n", cmd->adpcm.cmd);
                      PRINTF("\tflags: 0x%x = %s\n", cmd->setvol.flags,
                             "A_VOL | A_LEFT");
                      PRINTF("\tvol left: 0x%x\n", cmd->setvol.vol);
                      PRINTF("\tunused: 0x%x\n", cmd->setvol.voltgt);
                      PRINTF("\tunused: 0x%x\n", cmd->setvol.volrate);
                      PRINTF("\n");
                  }
                  else{
                      PRINTF("A_SETVOL: %d\n", cmd->adpcm.cmd);
                      PRINTF("\tflags: 0x%x = %s\n", cmd->setvol.flags,
                             "A_VOL | A_RIGHT");
                      PRINTF("\tvol right: 0x%x\n", cmd->setvol.vol);
                      PRINTF("\tunused: 0x%x\n", cmd->setvol.voltgt);
                      PRINTF("\tunused: 0x%x\n", cmd->setvol.volrate);
                      PRINTF("\n");
                  }
              }
              else if (cmd->setvol.flags & A_LEFT) {
                  PRINTF("A_SETVOL: %d\n", cmd->adpcm.cmd);
                  PRINTF("\tflags: 0x%x = %s\n", cmd->setvol.flags,
                         "A_RATE | A_LEFT");
                  PRINTF("\ttarget left: 0x%x\n", cmd->setvol.vol);
                  PRINTF("\tinteger rate left: 0x%x\n", cmd->setvol.voltgt);
                  PRINTF("\tfractional rate left: 0x%x\n",
                         cmd->setvol.volrate);
                  PRINTF("\trate left: %f\n", (1.0*cmd->setvol.voltgt) +
                         ((float)cmd->setvol.volrate/(float)0xffff));
                  PRINTF("\n");
              }
              else{
                  PRINTF("A_SETVOL: %d\n", cmd->adpcm.cmd);
                  PRINTF("\tflags: 0x%x = %s\n", cmd->setvol.flags,
                         "A_RATE | A_RIGHT");
                  PRINTF("\ttarget right: 0x%x\n", cmd->setvol.vol);
                  PRINTF("\tinteger rate right: 0x%x\n", cmd->setvol.voltgt);
                  PRINTF("\tfractional rate right: 0x%x\n",
                         cmd->setvol.volrate);
                  PRINTF("\trate right: %f\n", (1.0*cmd->setvol.voltgt) +
                         ((float)cmd->setvol.volrate/(float)0xffff));
                  PRINTF("\n");
              }
              break;

          case A_DMEMMOVE:
              PRINTF("A_DMEMMOVE: %d\n", cmd->adpcm.cmd);
              PRINTF("\tpad1: 0x%x\n", cmd->dmemmove.pad1);
              PRINTF("\tdmemin: 0x%x\n", cmd->dmemmove.dmemin);
              PRINTF("\tdmemout: 0x%x\n", cmd->dmemmove.dmemout);
              PRINTF("\tcount: 0x%x\n", cmd->dmemmove.count);
              PRINTF("\n");
              break;

          case A_LOADADPCM:
              PRINTF("A_LOADADPCM: %d\n", cmd->adpcm.cmd);
              PRINTF("\tpad1: 0x%x\n", cmd->loadadpcm.pad1);
              PRINTF("\tcount: 0x%x\n", cmd->loadadpcm.count);
              PRINTF("\tsegment: %d\n", cmd->loadadpcm.addr>>26);
              PRINTF("\tdram offset: 0x%x\n",
                     cmd->loadadpcm.addr & 0x03ffffff);
              PRINTF("\n");
              break;

          case A_MIXER:
              PRINTF("A_MIXER: %d\n", cmd->adpcm.cmd);
              PRINTF("\tflags: 0x%x\n", cmd->mixer.flags);
              temp = (float)((short)cmd->mixer.gain)/(float)0x7fff;
              PRINTF("\tgain: 0x%x, %f\n", cmd->mixer.gain, temp);
              PRINTF("\tdmemin: 0x%x\n", cmd->mixer.dmemi);
              PRINTF("\tdmemout: 0x%x\n", cmd->mixer.dmemo);
              PRINTF("\n");
              break;
                
          case A_INTERLEAVE:
              PRINTF("A_INTERLEAVE: %d\n", cmd->interleave.cmd);
              PRINTF("\tpad1: 0x%x\n", cmd->interleave.pad1);
              PRINTF("\tpad2: 0x%x\n", cmd->interleave.pad2);
              PRINTF("\tLeft input: %d\n", cmd->interleave.inL);
              PRINTF("\tRight input: %d\n", cmd->interleave.inR);
              PRINTF("\n");
              break;
                
          case A_POLEF:
              PRINTF("A_POLEF: %d\n", cmd->polef.cmd);
              PRINTF("\tflags: 0x%x\n", cmd->polef.flags);
              PRINTF("\tgain: %d\n", cmd->polef.gain);
              PRINTF("\tstate offset: 0x%x\n", cmd->polef.addr);
              PRINTF("\n");
              break;
                
          default:
              PRINTF("Unknown Acmd: 0x%x\n", cmd->adpcm.cmd);
              PRINTF("\tflags: 0x%x\n", cmd->adpcm.flags);
              PRINTF("\taud0ls: 0x%x\n", cmd->adpcm.gain);
              PRINTF("\taud1ms: %d\n", cmd->adpcm.addr>>16);
              PRINTF("\taud1ls: 0x%x\n", cmd->adpcm.addr & 0xffff);
              PRINTF("\n");
              break;
        }        
    }

    PRINTF("Done parsing audio command list\n\n");

}