/*
 * hifi.c:
 *
 * Copyright (c) 2000 James McKenzie <james@fishsoup.dhs.org>.
 * All rights reserved.
 *
 * $Log: hifi.c,v $
 * Revision 1.8  2000/09/29 07:53:48  root
 * #
 *
 * Revision 1.7  2000/09/29 07:53:02  root
 * #
 *
 * Revision 1.6  2000/09/24 01:12:53  root
 * #
 *
 * Revision 1.5  2000/09/19 09:36:01  root
 * #
 *
 * Revision 1.4  2000/02/20 18:23:01  root
 * #
 *
 * Revision 1.3  2000/02/20 03:17:22  root
 * #
 *
 * Revision 1.2  2000/02/20 03:16:39  root
 * #
 *
 * Revision 1.1  2000/02/20 02:51:44  root
 * #
 *
 *
 */

static char rcsid[] = "$Id: hifi.c,v 1.8 2000/09/29 07:53:48 root Exp $";

#include "project.h"

#define MSGDEBUG 0

Byte hifi_msgbuf[1024];

#if MSGDEBUG
char buf[1024];
#endif

void
hifi_valid_cmd (Byte sclass, Byte sunit, Byte dclass, Byte dunit, Word cmd,
                Byte * data, Word len)
{
#if MSGDEBUG
  char *ptr = buf;
#endif
  int y;
//Byte class;
  //class=HIFI_STCMD_CLASS(cmd);

  if ((dclass != HIFI_CLASS_ALL) && (dclass != HIFI_CLASS_DISPLAY))
    return;
  if ((dunit != HIFI_UNIT_ALL) && (dunit != displayunit))
    return;


  switch (sclass)
    {
    case HIFI_CLASS_OGG:
      ogg_cmdst_message (sunit, cmd, data, len);
      system_cmdst_message (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_MPEG:
      mpeg_cmdst_message (sunit, cmd, data, len);
      system_cmdst_message (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_TUNER:
      tuner_cmdst_message (sunit, cmd, data, len);
      system_cmdst_message (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_CD:
      cd_cmdst_message (sunit, cmd, data, len);
      system_cmdst_message (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_WAVE:
      wave_cmdst_message (sunit, cmd, data, len);
      system_cmdst_message (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_SYSTEM:
      system_cmdst_message (sclass, sunit, cmd, data, len);
      break;
    case HIFI_CLASS_CLOCK:
      system_cmdst_message (sclass, sunit, cmd, data, len);
      break;
    }


#if MSGDEBUG

  y = 120;
  y += 10 * (cmd & 3);
  sprintf (buf, "%04x:", cmd);
  ptr = buf + 5;
  while (len--)
    {
      sprintf (ptr, "%02x", *(data++));
      ptr += 2;
    }

  *ptr = 0;

  WinDrawChars (buf, StrLen (buf), 20, y);
#endif

}


int
hifimsg_send (void *lib, Byte * ptr, Word len)
{
  return irda_send_data (ptr, len);
}
