📄 aviplay.c
字号:
/** \file aviplay.c Experimental functions to play sound track from AVIfile */#define btUNKNOWN 0#define btLIST 1#define btSTR 2#define btAUDIO 3#define GetLongWord() {instream.b.b0 = FGetChar(); \ instream.b.b1 = FGetChar();\ instream.b.b2 = FGetChar();\ instream.b.b3 = FGetChar();}void GetAVIBlock(){ xdata addressType instream; xdata unsigned char blockType = 0; bit isPadded = 0; GetLongWord(); if ((instream.b.b2 == 'w') && (instream.b.b3 == 'b')){ blockType = btAUDIO; } if (instream.l==1414744396){ //LIST blockType = btLIST; } GetLongWord(); //instream.l should now contain the chunk size. //its length must be even by spec. if it's odd, a pad byte is //in the file but its NOT part of chunk data. if (instream.b.b0&1){ isPadded = 1; //There is a pad byte to make chunk len even }else{ isPadded = 0; } if (blockType == btAUDIO){ //--------THIS PACKET IS SENT TO VS10xx--------- //superbly hilarious effects could happen if the avifile has //more than 1 soundtrack as all of them would be sent to VS10xx while(instream.l){ unsigned char c; while ((instream.l>16)&&(dataBufPtr < diskSect.raw.buf+496)){ //We have at least 16 octets of continuous stream in mem. if (!MP3_DREQ){ GREEN_LED = LED_ON; while (!MP3_DREQ){ Mp3DeselectData(); AvailableProcessorTime(); } } GREEN_LED = LED_OFF; Mp3SelectData(); SPIPutCharWithoutWaiting(*dataBufPtr++); SPIWait(); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); SPIPutChar(*dataBufPtr++); instream.l-=16; fileSize-=16; SPIWait(); } MP3_XDCS=1; instream.l--; c=FGetChar(); //data comes first until end of sector and //then a new sector is loaded automagically. MP3_XDCS=0; SPIPutCharWithoutWaiting(c); //SPIWait(); } MP3_XDCS=1; }else if (blockType == btLIST){ ConsoleWrite("\rAVI: List of "); GetLongWord(); ConsolePutChar(instream.b.b0); ConsolePutChar(instream.b.b1); ConsolePutChar(instream.b.b2); ConsolePutChar(instream.b.b3); }else{ //We don't need this chunk. Let's quickly skip over it. //Is pad byte insertion needed? if (isPadded){ instream.l++; //instream.l contains chunk size isPadded = 0; } //Skip to the end of sector if (instream.l>(temp.i=diskSect.raw.buf+512-dataBufPtr)){ //The packet continues after end of sector instream.l -= temp.i; fileSize -= temp.i; sectorAddress.l++; //Sector handled, go to next. dataBufPtr = 0; //Complete sector is handled. } //Skip unnecessary sectors if (instream.l>512){ while (instream.l>512){ sectorAddress.l++; instream.l -= 512; fileSize -= 512; } dataBufPtr = 0; //Initialize for next call to FGetChar(); } //Read last sector into memory if (dataBufPtr == 0){ ReadDiskSector(sectorAddress.l); dataBufPtr = diskSect.raw.buf; } while (instream.l--){ dataBufPtr++; } }//nothing interesting,skip block if (isPadded){ FGetChar(); } }/** Try to play an avi file at current sector. * Returns 0x11 if AVI header is not found, * 0 if the file is played. */unsigned char PlayAvi(){ ReadDiskSector(sectorAddress.l); //DumpDiskSector(); if (diskSect.raw.buf[8]!='A') return 0x11; if (diskSect.raw.buf[9]!='V') return 0x11; if (diskSect.raw.buf[10]!='I') return 0x11; ConsoleWrite("\rPlayAvi()\r"); dataBufPtr=diskSect.raw.buf+12; while(fileSize){ GetAVIBlock(); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -