⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osd.c

📁 winboard vcd software
💻 C
📖 第 1 页 / 共 5 页
字号:

//, CHAR_VSYMBOL1, CHAR_VSYMBOL2, CHAR_VSYMBOL3, CHAR_VSYMBOL4, CHAR_VSYMBOL5};
//BYTE code aMsgBar[]     = {5, 43, 44, 45, 46, 47};
BYTE code aMsgMuteOn[]  = {2, CHAR_MUTE1, CHAR_MUTE2};
BYTE code aMsgMuteOff[]  = {4, CHAR_MUTE1, CHAR_MUTE2, CHAR_CANCEL1, CHAR_CANCEL2};
BYTE code aMsgRandomOn[]= {4, CHAR_RANDOM1, CHAR_RANDOM2, CHAR_PLAY1, CHAR_PLAY2};
BYTE code aMsgRandomOff[]={4, CHAR_ORDER1,CHAR_ORDER2,CHAR_PLAY1, CHAR_PLAY2};
BYTE code aMsgRepeatA[] = {4, CHAR_REPEAT1, CHAR_REPEAT2, CHAR_SPACE, CHAR_A};
BYTE code aMsgRepeatAB[] ={6, CHAR_REPEAT1, CHAR_REPEAT2, CHAR_SPACE, CHAR_A, CHAR_DASH, CHAR_B};
BYTE code aMsgRepeatTrack[]={4, CHAR_REPEAT1, CHAR_REPEAT2, CHAR_SINGLE1, CHAR_SINGLE2};
BYTE code aMsgRepeatDisc[]= {4, CHAR_REPEAT1, CHAR_REPEAT2, CHAR_WHOLE, CHAR_DISC2};
BYTE code aMsgRepeatAll[]=  {4, CHAR_REPEAT1, CHAR_REPEAT2, CHAR_DISC1, CHAR_DISC2};
BYTE code aMsgRepeatNone[]={4, CHAR_REPEAT1, CHAR_REPEAT2, CHAR_CANCEL1, CHAR_CANCEL2};
BYTE code aMsgPBCon[]     = {4, CHAR_P, CHAR_B, CHAR_C, CHAR_OPEN};
BYTE code aMsgPBCoff[]     = {4, CHAR_P, CHAR_B, CHAR_C, CHAR_CLOSE};
BYTE code aMsgOn[]      = {1, CHAR_OPEN};
BYTE code aMsgOff[]     = {1, CHAR_CLOSE};
BYTE code aMsgNTSC[]    = {4, CHAR_N, CHAR_T, CHAR_S, CHAR_C};
BYTE code aMsgPAL[]     = {3, CHAR_P, CHAR_A, CHAR_L};
BYTE code aMsgAuto[]    = {4, CHAR_A, CHAR_U, CHAR_T, CHAR_O};
BYTE code aMsgTV[]      = {2, CHAR_TV1, CHAR_TV2};
BYTE code aMsgNormal[]  = {2, CHAR_VOLUME1, CHAR_TONE};
BYTE code aMsgStereo[]  = {3, CHAR_STEREO1, CHAR_STEREO2, CHAR_CHANNEL1};
BYTE code aMsgLChannel[]= {3, CHAR_LEFT, CHAR_CHANNEL1, CHAR_CHANNEL2};
BYTE code aMsgRChannel[]= {3, CHAR_RIGHT, CHAR_CHANNEL1, CHAR_CHANNEL2};
BYTE code aMsg3DAudio[]= {2, CHAR_3, CHAR_D};   // *** TCH;


BYTE code aMsgOpen[]    = {8, CHAR_OPEN, CHAR_DOOR, CHAR_N_OPEN,CHAR_SPACE,CHAR_PLEASE,CHAR_CHANGE,CHAR_DISC1,CHAR_DISC2};
BYTE code aMsgClose[]   = {2, CHAR_CLOSE, CHAR_DOOR };
BYTE code aMsgNext[]    = {4, CHAR_NEXT1, CHAR_NEXT2, CHAR_SINGLE2,CHAR_N_NEXT};
BYTE code aMsgPrev[]    = {4, CHAR_PREV1, CHAR_PREV2, CHAR_SINGLE2,CHAR_N_PRE};
BYTE code aMsgReturn[]  = {3, CHAR_RETURN1, CHAR_RETURN2,CHAR_N_RETURN};
BYTE code aMsgPlay[]    = {3, CHAR_PLAY1, CHAR_PLAY2,CHAR_N_PLAY};
BYTE code aMsgStop[]    = {3, CHAR_STOP1, CHAR_STOP2,CHAR_N_STOP};
BYTE code aMsgScanF[]    = {3, CHAR_FAST1, CHAR_FORWARD,CHAR_N_SCANF};
BYTE code aMsgScanB[]    = {3, CHAR_FAST1, CHAR_BACKWARD,CHAR_N_SCANB};
BYTE code aMsgPause[]   = {3, CHAR_PAUSE1, CHAR_PAUSE2,CHAR_N_PAUSE};
BYTE code aMsgWeiFang[] = {2, CHAR_WEI,CHAR_PLAY2};
#endif

#ifndef  NO_OSD
// bitmap fonts array
BYTE code Chinese[CHAR_NUMBERS*60]=
{
#include "fonts.txt"
};
#endif  //#ifndef  NO_OSD

BYTE _OSD_FilterLeftMessage(BYTE bMessage, WORD wParam, BYTE bSec);
BYTE _OSD_FilterRightMessage(BYTE bMessage, WORD wParam, BYTE bSec);
BYTE    bBitmapIndex1[14+1];
BYTE    bBitmapIndex0[11+1];
BYTE    bCurrentMessage;
WORD    wGuideLength=0;
extern BIT gbtMP2Title;
//  *********************************************************************
//  Function    :   _OSD_GetTotalColumns
//  Description :   Pre-calculate the total columns used for the message
//                  for right alignment use
//  Arguments   :   bIndex      : the pointer to bitmap index array
//  Return      :   the total columns use
//  Side Effect :
//  *********************************************************************
BYTE _OSD_GetTotalColumns(BYTE bIndex[])
{
    BYTE    bTotalColumns=0;
    BYTE    i;
    // index 0 to 0x5f, means use internal OSD font
    // index >=0x60, means use etxernal OSD font
    for (i=0;i<bIndex[0];i++)
    {
        if (bIndex[i+1]<EXTERN_FONT_INDEX)   // the index means an internal font
            bTotalColumns+=ENGLISH_COLUMNS;
        else                    // the index means an external font
            bTotalColumns+=CHINESE_COLUMNS;
    }
    return bTotalColumns;
}
//  *********************************************************************
//  Function    :   _OSD_SetDisplayArray
//  Description :   Prepare the _dwDisplayArray with the row/col/bitmap index
//                  information
//  Arguments   :   bIndex      : the chars offset (0-based)
//                  bBitmapRAM  : access which bitmap RAM
//                  _bReAssignIndex : TRUE, will use external bitmap RAM
//                                    (_bInternalIndex will be used)
//                                  : FALSE, will use internal bitmap RAM
//  Return      :   NULL
//  Side Effect :
//  *********************************************************************
void _OSD_SetDisplayArray(BYTE bIndex, BYTE bBitmapRAM)
{
    DWORD    dwDisplayRAMData;

    if (!_bReAssignIndex)   // use internal bitmap ROM
    {
        bIndex=_bInternalIndex;
    }
    else
    {
        if (!bBitmapRAM)  // bitmap RAM 0
        {
            bIndex+=EXTERN_FONT_INDEX;
        }
        else                //bitmap RAM 1
        {
            bIndex+=EXTERN_FONT_INDEX+BITMAP0_MAX_FONTS;
        }
    }
//    if(_btREVERSEON)_dwReverseEffect=OSD_REVERSE_ON ;
    dwDisplayRAMData=bIndex;        // bits 6-0, for char index
    dwDisplayRAMData|=(DWORD)(__iCol)<<7;    // bits 13-7, for column index
    dwDisplayRAMData|=(DWORD)(__iRow)<<14;   // bits 17-14, for row index
    dwDisplayRAMData|=_dwColorIndex;         // bits 19-18, use color index 03
//    dwDisplayRAMData|=OSD_REVERSE_EFFECT;    // bits 20, for reverse display
    dwDisplayRAMData|=_dwReverseEffect;    // bits 20, for reverse display
    if (_wDisplayChars>MAX_DISPLAY)
        return;

    _dwDisplayArray[++_wDisplayChars]=dwDisplayRAMData;
    // increase column address for next char
    if (_bReAssignIndex)
    {
        __iCol+=CHINESE_COLUMNS;
    }
    else
    {
        __iCol+=ENGLISH_COLUMNS;
    }
    _bReAssignIndex=FALSE;
  //  _dwReverseEffect=OSD_REVERSE_OFF;
}

//  *********************************************************************
//  Function    :   _OSD_BuildNewFonts
//  Description :   Build the bitmap fonts into bitmap RAM 0 or 1
//  Arguments   :   external parameters:
//                  _bIndexOffset: the first char offset to the bitmap RAM
//                  _bIndexArray: store number of birmap fonts to build and
//                                the index to bitmap fonts array
//                  _btBitmapRAM    : access which bitmap RAM
//                  _btPrepareData  : TRUE, prepare the displat RAM data(default)
//                                    FALSE, build bitmap font only
//  Return      :   NULL
//  Side Effect :
//  *********************************************************************
void _OSD_BuildNewFonts()
{
#ifndef  NO_OSD
    // for check the PSR status
    WORD        wPSR;
    // time counter for checking VSYNC interrupt time out
    WORD        wInitialTime;
    // bitmap font data
    WORD    wFontData;
    // counter for bitmap fonts
    BYTE    bFontCount;
    BYTE    bFont1, bFont2, bFont3;
    BYTE    bStartIndex;
    WORD    wCharStart;

    // reset the build chars no.
    bFontCount=0;
    if (!_btBitmapRAM)
    {
        bStartIndex=_bIndexOffset;
    }
    else
        bStartIndex=_bIndexOffset+11;

    // build the fonts specified in _bIndexArray
    while (bFontCount < _bIndexArray[0])
    {
        // number of chars still not build=
        // (total chars to build) - (no of chars build)
        _bNoChars=_bIndexArray[0]-bFontCount;
        if (!_bNoChars) // all the chars are built
            break;

        // reset time counter
        wInitialTime=NULL;
        // store current 8051 interrupt enable status
//        _bEA=EA;
        // disable all 8051 interrupt
//        EA=0;


#if 0
        // clear VSYNC interrupt
        W9925_WriteReg(ISR,PSR_VSYN);
        // wait VSYNC interrupt
        while (wInitialTime < 1000)
        {
            // read PSR status
            wPSR=W9925_ReadReg(PSR);
            if (wPSR & PSR_VSYN)
            {
                // VSNC interrupt
                break;
            }

            //can't use __wTemp as a counter
            //it will cause leaving the waiting loop without VSYNC interrupt.
            wInitialTime++;
        }

        // disable OSD display in the VSYNC blank time
        // will have no effect for visual effect
        // write OSDCR with 0 first
        W9925_WriteReg(OSDCR,0);//_wOSDEffect);  // temporarily disable OSD
        // set starting address to access bitmap RAM
#endif

        //each VSYNC blank write _bMaxFonts char font
        for (k=0;k<_bNoChars;k++)
        {
            // increase char font count
            bFontCount++;

            if (_bIndexArray[bFontCount]<EXTERN_FONT_INDEX)  // internal bitmap ROM
                continue;
            // get the index to Chinese array from _bIndexArray
            wCharStart=(_bIndexArray[bFontCount]-INDEX_BASE) * (CHAR_BYTES * CHAR_HEIGHT);

            // reset counter
            l=0;
            // each bitmap font takes 20 dword
            // the first char offset plus the build chars count =
            // the offset of next char to build
            _wAddress=0x400+((bStartIndex+(bFontCount-1))*40)-1;
            // the access for DRAM must decrease the address by 1
            // only the LSB 14 bits are used for address
            _wAddress&=0x3fff;
            _wAddress|=0x8000;
            _bEA=EA;
            // disable all 8051 interrupt
            EA=0;
            W9925_OutIndex(_wAddress);
            // each char font need 20 words data
            while (l<CHAR_HEIGHT)
            {
                // get the font from Chinese array
                bFont1=Chinese[wCharStart++];
                bFont2=Chinese[wCharStart++];
                bFont3=Chinese[wCharStart++];
                W9925_OutData(bFont1);
                OUTB(DPR1,bFont2);
                OUTB(DPR0,bFont3);
                l++;
            }       // end writing a char font
            EA=_bEA;
        }       // end writing _bMaxFonts char font
    }

    // after build bitmap RAM
    // must prepare the Display RAM data to _dwDisplayArray
    if (_btPrepareData)
    {
        for (k=0;k<_bIndexArray[0];k++)
        {
            // a display char need row/col/index/which bitmap RAM information
            // the __iRow/__iCol values are already set before calling
            // BC5380
            if (_bIndexArray[k+1] >= EXTERN_FONT_INDEX) // internal bitmap ROM
            {
                _bReAssignIndex=TRUE;
            }
            else
                _bInternalIndex=_bIndexArray[k+1];
            if (k >=_wReverseFrom)
            {
                _dwReverseEffect=OSD_REVERSE_ON;
            }
            _OSD_SetDisplayArray(_bIndexOffset+k, _btBitmapRAM);
        }
    }

    // default always prepare the display RAM data
    _btPrepareData=TRUE;
#endif  //#ifndef  NO_OSD
}

//  *********************************************************************
//  Function    :   _OSD_OutDisplayRAM
//  Description :       Write the _dwDisplayArray data to display RAM
//  Arguments   :   bDigit      : the first data to write(0-based)
//                                      bChars  : no of data to write
//  Return      :   NULL
//  Side Effect :
//  *********************************************************************
void _OSD_OutDisplayRAM(BYTE bDigit, BYTE bChars)
{
#ifndef  NO_OSD
    DWORD dwData;
    static WORD wDisplayBank=BANK_0;
    BYTE bDisplayStart=0;
    WORD        wPSR;
    WORD        wInitialTime;

    // BC5380 must two bank switching!!!
    // or DIGEST H/W OSD display will flash
// /*
    if (wDisplayBank!=BANK_1)
        bDisplayStart=0;
    else
        bDisplayStart=128;
// */

    // the first index to _dwDisplayArray
    k=bDigit+1;         // the first display data is in _dwDisplayArray[1]

    // display RAM start address = 0x8000
    // but must decrease the address by 1 for each access
    // set the starting address for the first data
    _wAddress=((bDigit+bDisplayStart)<<1)-1;
    _wAddress&=0x3FFF;   // 14 bits valid
    _wAddress |=0x8000;

    // write 0 chars, must disable OSD
    if (bChars==0)
    {
        //BC5380
        // can directly write display RAM
        // with end code,
        _bEA=EA;
        EA=0;
        W9925_OutIndex(0xBFFF);
//        W9925_OutData(0x0000);
//        W9925_OutData(0x0000);
        W9925_OutData(0xFFFF);
        W9925_OutData(0xFFFF);
        EA= _bEA;
        // disable OSD
        W9925_WriteReg(OSDCR, 0xC000);
        return;
    }


    // must disable interrupt !!!
    // to avoid index is changed before writing data
//    _bEA=EA;
//    EA=0;

    l=0;

    while (l < bChars)      //continue writing display RAM
    {
        _wAddress=((l+bDisplayStart)<<1)-1;
        _wAddress&=0x3FFF;   // 14 bits valid
        _wAddress |=0x8000;
        // get data from _dwDisplayArray
        dwData=_dwDisplayArray[k];      // contain the data for display RAM
        _bEA=EA;
        EA=0;
        W9925_OutIndex(_wAddress);
        W9925_OutData(HIWORD(dwData));  // write DATA to display RAM

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -