home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fujiology Archive
/
fujiology_archive_v1_0.iso
/
!FALCON
/
NOCREW
/
MP2_0997.ZIP
/
mp2_0997
/
src
/
decoder.tml
< prev
next >
Wrap
Text File
|
1999-07-12
|
2KB
|
123 lines
/* decoder.c
*
* COPYRIGHT (c) 1998 by NoCrew Laboratories.
*
* MPEG audio layer 2 decoder.
*/
#include <tos.h>
#include "dsp.h"
#include "types.h"
#include "stream.h"
#include "snddefs.h"
static Byte decoder_program[] = {
$ };
Int decoder_dsp_acknowledge(void);
extern int replay;
/*
* Darn slow, but that's the way it
* is when we can't use supervisor mode.
*/
static void dsp_send(Int x)
{
Dsp_BlkUnpacked(&x, 1, 0, 0);
}
static Int dsp_receive(void)
{
Int r;
Dsp_BlkUnpacked(0, 0, &r, 1);
return r&0x00800000L?r|0xff000000L:r;
}
/*
* RPC (Remote Procedure Call) functions.
*/
static void dsp_rpc(Int n)
{
dsp_send(-(n+1));
}
static Int dsp_frpc(Int n)
{
if(decoder_dsp_acknowledge()) {
dsp_rpc(n);
return dsp_receive();
} else {
return 0;
}
}
static Int dsp_rpc_timeout(Int n)
{
return dsp_send_timeout(-(n+1));
}
static Int dsp_frpc_timeout(Int n)
{
return dsp_rpc_timeout(n)==1?dsp_receive_timeout():0x80000000L;
}
void decoder_add_available(Int bytes)
{
dsp_send(bytes/2);
}
Int decoder_current_load(void)
{
if(replay)
return dsp_frpc(7);
else
return 0;
}
Int decoder_average_load(void)
{
if(replay)
return dsp_frpc(8);
else
return 0;
}
Int decoder_stream_available(void)
{
return dsp_frpc(9)*2;
}
Int decoder_dsp_acknowledge(void)
{
return dsp_frpc_timeout(2) == 0x6d7032L;
}
Int decoder_dma_acknowledge(void)
{
Int r;
char s[] = { 0xff,0x4e,0x6f,0x43,0x72,0x65,0x77,
0x20,0x72,0x75,0x6c,0x65,0x73,0x21 };
buffoper(0);
for(r = 0; r < sizeof(s); r++)
((char*) stream_get_buffer())[r] = s[r];
buffoper(SB_PLA_ENA | SB_PLA_RPT);
r = dsp_frpc_timeout(3) == 0x646d61L;
buffoper(0);
return r;
}
/*
* Load DSP MPEG audio layer 2 decoder.
*/
Int decoder_load(void)
{
return dsp_load_program(decoder_program, sizeof(decoder_program)/3);
}