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

📄 gdi.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif
DWORD   _dwGDITemp;
DWORD   _dwGDIHeaders[4]; // temp use, should be able to use that of OSD.C

// Internal to GDI module
PARM_RECT _GDIRect;
GDI_PARAMETER _GDIParm0;

DWORD * _pdwGDIPTR;    // a point to DWORD unit


BYTE _gdi_CommandN(BYTE bCommandID);


#endif //NO_GDI



BYTE    __bCurrentRegionId; // the cuurent region ID, which is referenced by many functions
WORD    __wGDIString[GDI_STRING_LENGTH+1];

GDI_PARAMETER __GDIParm; // Global for all
WORD __wGDIx, __wGDIy;

WORD __wGDIStartX, __wGDIStartY; // used only for GDI_MoveRegion

// Brian1.00, this global is used as a "parameter" for Macro.
// Currently it is only used by GDI_OUTPUT_TEXT
BYTE __bGDIMacroParam; 

// Brian1.08, use global variable to replace ColorMode field of region
BYTE __bColorMode;

// Brian, CT908S
// this is used for change region height between 640x460 (8-bit oe 4-bit mode), 640x98 (4-bit mode)
DWORD   __dwRegionHeight;
DWORD   __dwRegionTAddr;
DWORD   __dwRegionBAddr;


#ifdef NO_GDI
BYTE code GDIDummy[]={0};
#endif

//extern BYTE __bOSDDisabled;

// Chuan1.00-2, add 'A', 'B', 'C', 'D', 'E', 'F' for Hex display
WORD code aDigits[] = {CHAR_0, CHAR_1, CHAR_2, CHAR_3, CHAR_4, CHAR_5, CHAR_6, CHAR_7, CHAR_8, CHAR_9, CHAR_A, CHAR_B, CHAR_C, CHAR_D, CHAR_E, CHAR_F};


// Brian2.37, 
BYTE _bNormalFontableAddress;
extern DWORD _dwTopAddr;
extern DWORD _dwBottomAddr;
extern DWORD _dwTopSize;
extern DWORD _dwBottomSize;


extern void GDI_LoadBMPResource_1(void);
extern void GDI_LoadBMPResource_2(void);
extern void GDI_LoadBMPResource_3(void);

void GDI_ClearRegion_By_RISC(BYTE bRegionId);
void _GDI_SetCMDRam(void);

extern void Service_420(void);
//  *********************************************************************
//  Function    :   GDI_Initial
//  Description :   This function initializes the GDI environment
//  Arguments   :   None
//  Return      :   None
//  Side Effect :
//  Note        :   It will do the following task:
//                  [1] Download font table to DRAM
//                  [3] Load palette 0 (assign entry 255 as transparent color)
//                  [4] Set palette entries used by GDI module
//                  [5] Initialize region 0, 1 and 2 (and clear these regions)
//                  [6] Load BMP resource from code array into OSD region
//                  [7] Set current region to region 0
//  *********************************************************************

void GDI_Initial(void)
{
#ifndef NO_GDI
/*
    printf("\nPAL_ADDR = %x\n", PAL_ADDR);
    printf("OSD_DRAM_FONT_TABLE_START_0 = %x\n", OSD_DRAM_FONT_TABLE_START_0);
    printf("OSD_DRAM_FONT_TABLE_START_1 = %x\n", OSD_DRAM_FONT_TABLE_START_1);
    printf("REGION_T_ADDR0 = %x\n", REGION_T_ADDR0);
    printf("REGION_T_ADDR1 = %x\n", REGION_T_ADDR1);
    printf("REGION_T_ADDR2 = %x\n", REGION_T_ADDR2);
    printf("REGION_B_ADDR0 = %x\n", REGION_B_ADDR0);
    printf("REGION_B_ADDR1 = %x\n", REGION_B_ADDR1);
    printf("REGION_B_ADDR2 = %x\n", REGION_B_ADDR2);
    printf("OSD End = %x\n", REGION_B_ADDR2+(REGION_BUFFER_2_SIZE/2) + (GDI_REGION_WIDTH>>2));
*/

	GDI_LoadPalette(0); //CoCo, Initialize palette at the beginning.
	GDI_SetGDIPalEntry(); //CoCo, Initialize palette at the beginning.

    // Brian1.08, initialize color mode
    __bColorMode = COLOR_MODE_4_BIT;

    // [1]  Download Font table.
    // This is for GXA in emulator only. S/W emulation method get font data from code array directly.
#ifdef GDI_EMULATION
    // Download font table from file to DRAM
    // This is for GXA used in emulator 
    //_DownloadTable();
#endif

#if 0 //LJY1.00-4, move to INITIAL_PowerONStatus(), only need to do once after H/W power-on.
    OSD_LoadFontTableHDW();
    OSD_LoadFontTableLDW();
#endif
    // [2]  Set DRAM variables for GDI

    // Brian0.84a-2nd, add Top/Bottom for RISC reference
#ifdef USE_ONE_OSD_REGION

#ifdef MINI_OSD_REGION // CT908S
    _dwGDIHeaders[0]=( __dwRegionTAddr | ((DWORD)__bColorMode <<27) );
    _dwGDIHeaders[1]=( __dwRegionBAddr | ((DWORD)__bColorMode <<27) );
#else
    _dwGDIHeaders[0]=( __RegionList[0].dwTAddr | ((DWORD)__bColorMode <<27) );
    _dwGDIHeaders[1]=( __RegionList[0].dwBAddr | ((DWORD)__bColorMode <<27) );
#endif

#else //#ifdef USE_ONE_OSD_REGION
    _dwGDIHeaders[0]=( __RegionList[0].dwTAddr | ((DWORD)__RegionList[0].bColorMode <<27) );
    _dwGDIHeaders[1]=( __RegionList[0].dwBAddr | ((DWORD)__RegionList[0].bColorMode <<27) );
#endif

    W99AV_WriteDRAMData(CT908_DRAM_REG_BASE_TOP, _dwGDIHeaders[0]);
    W99AV_WriteDRAMData(CT908_DRAM_REG_BASE_BOT, _dwGDIHeaders[1]);

    //W99AV_ReadDRAMData(CT908_DRAM_REG_BASE_TOP, &_dwGDIHeaders[0]);
    //printf("CT908_DRAM_REG_BASE_TOP=%lx\n", _dwGDIHeaders[0]);
    //W99AV_ReadDRAMData(CT908_DRAM_REG_BASE_BOT, &_dwGDIHeaders[0]);
    //printf("CT908_DRAM_REG_BASE_BOT=%lx\n", _dwGDIHeaders[0]);

    // [3]  Assign palette entry 255 as the transparency color  
    //GDI_LoadPalette(0); //--CoCo, move it to the beginning.
  
    // [4]  Set palette entries used by GDI module
    //GDI_SetGDIPalEntry(); //--CoCo, move it to the beginning.

    // [5]  Initialize region 0, 1 and 2 (and clear these regions)

    // [5.1] Clear region 3 with write DRAM data
/*
    GDI_InitialRegion(3);
    for (_bGDITemp=0; _bGDITemp<4; _bGDITemp++)
        _dwGDIHeaders[_bGDITemp] = MAKELONG(MAKEWORD(PAL_ENTRY_COLOR_TRANSPARENT, PAL_ENTRY_COLOR_TRANSPARENT), MAKEWORD(PAL_ENTRY_COLOR_TRANSPARENT, PAL_ENTRY_COLOR_TRANSPARENT));
    _dwGDITemp = GDI_REGION_3_WIDTH/(1L << (2-__RegionList[3].bColorMode));
    _dwGDITemp = _dwGDITemp >> 4; // how many 4-DWORD in one line
    _wGDITemp = 0;
    for (__bTemp=0; __bTemp<__RegionList[3].wHeight/2; __bTemp++)
    {
        for (__wTemp=0; __wTemp < _dwGDITemp; __wTemp++)
        {
            // Top/Bottom use the same field buffer
            W99AV_WriteDRAMBurst( __RegionList[3].dwTAddr+4+_wGDITemp, _dwGDIHeaders, 4);
            //W99AV_WriteDRAMBurst( __RegionList[3].dwBAddr+4+_wGDITemp, _dwGDIHeaders, 4);
            _wGDITemp += 4;
        }
    }
    GDI_SetCurrentRegion(3);
    GDI_ActivateRegion();
*/

    // [5.2] Initialize region 0
    // Brian1.08, initialize color mode
    __bColorMode = COLOR_MODE_4_BIT;

    GDI_InitialRegion(0);
    GDI_SetCurrentRegion(0);
    //GDI_ClearRegion_By_RISC(0); // move to W99AV_PowerOnInitial
    // Brian0.85, change to region 0, so the next Clear Region can be faster
    //GDI_ActivateRegion();

#ifndef USE_ONE_OSD_REGION
    // [5.3] Initialize region 1
    // Brian1.08, initialize color mode
    __bColorMode = COLOR_MODE_8_BIT;

    GDI_InitialRegion(1);
    GDI_SetCurrentRegion(1);
    //GDI_ClearRegion_By_RISC(1); // move to W99AV_PowerOnInitial
#endif

#ifndef MINI_OSD_REGION // CT908S
    // [5.4] Initialize region 2
    // Brian1.08, initialize color mode
    __bColorMode = COLOR_MODE_8_BIT;

    GDI_InitialRegion(2);
    GDI_SetCurrentRegion(2);
    //GDI_ClearRegion_By_RISC(2); // move to W99AV_PowerOnInitial
#endif


    // [5.5] Deactive the region
    GDI_DeactivateRegion();

#if (!defined(REMOVE_SETUP_ICON)) || (!defined(REMOVE_SETUP_SPEAKER_TEST))
    // [6] Load BMP resource from code array into OSD region (2)
#ifdef  SUPPORT_DVD_T
    if (!__bReduceSTBtoDVDtime)   //Kevin1.24aDVD_T, no load bitmap when switching from STB->DVD  
#endif  
    GDI_LoadBMPResource();
#endif

    // [7] Set current region to region 0
    // Brian1.08, initialize color mode
    __bColorMode = COLOR_MODE_4_BIT;

    GDI_SetCurrentRegion(0);

    // Brian0.86
    // Set OSD region position correctly according to TV modee and P-SCAN mode
    OSD_FillHeadtoDRAM(0);

    //_bGDIInit = 1; // Brian2.31, remove it, no one reference

#endif //#ifndef NO_GDI
 }

//  *********************************************************************
//  Function    :   GDI_SetGDIPalEntry
//  Description :   This function sets the palette entries used by GDI module
//  Arguments   :   None
//  Return      :   None
//  Side Effect :
//  *********************************************************************

void GDI_SetGDIPalEntry(void)
{
#ifndef NO_GDI

    //Brian0.86
#ifdef GDI_4_BIT_OSD
    // load transparent color to ebtry 15
    GDI_LoadPalette(3);

    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_BRIGHT, GDI_VALUE_4B_COLOR_BRIGHT, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_DARK, GDI_VALUE_4B_COLOR_DARK, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_CENTER, GDI_VALUE_4B_COLOR_CENTER, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_BAR_BG, GDI_VALUE_4B_COLOR_BAR_BG, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_GENERAL_BG_BLACK, GDI_VALUE_4B_COLOR_GENERAL_BG_BLACK, TRUE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_GENERAL_BG_BLUE, GDI_VALUE_4B_COLOR_GENERAL_BG_BLUE, TRUE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_GREEN, GDI_VALUE_4B_COLOR_GREEN, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_YELLOW, GDI_VALUE_4B_COLOR_YELLOW, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_ORANGE, GDI_VALUE_4B_COLOR_ORANGE, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_BLACK, GDI_VALUE_4B_COLOR_BLACK, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_TEXT_DISABLED, GDI_VALUE_4B_COLOR_TEXT_DISABLED, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_RED, GDI_VALUE_4B_COLOR_RED, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_ORANGE_TRANSPARENT, GDI_VALUE_4B_COLOR_ORANGE_TRANSPARENT, TRUE);
    GDI_ChangePALEntry(GDI_ENTRY_4B_COLOR_BUTTON_NORMAL, GDI_VALUE_4B_COLOR_BUTTON_NORMAL, FALSE);

#endif 


    GDI_ChangePALEntry(GDI_ENTRY_SCROLL_BAR_COLOR_BRIGHT, GDI_VALUE_SCROLL_BAR_COLOR_BRIGHT, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_SCROLL_BAR_COLOR_DARK, GDI_VALUE_SCROLL_BAR_COLOR_DARK, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_SCROLL_BAR_COLOR_CENTER, GDI_VALUE_SCROLL_BAR_COLOR_CENTER, FALSE);
    GDI_ChangePALEntry(GDI_ENTRY_SCROLL_BAR_COLOR_BG, GDI_VALUE_SCROLL_BAR_COLOR_BG, FALSE);

    //GDI_ChangePALEntry(GDI_ENTRY_BUTTON_COLOR_NORMAL, GDI_VALUE_BUTTON_COLOR_NORMAL, FALSE);
    //GDI_ChangePALEntry(GDI_ENTRY_BUTTON_COLOR_HIGHLIGHT, GDI_VALUE_BUTTON_COLOR_HIGHLIGHT, FALSE);
    //GDI_ChangePALEntry(GDI_ENTRY_BUTTON_COLOR_DISABLE, GDI_VALUE_BUTTON_COLOR_DISABLE, FALSE);
#endif 
}

//  *********************************************************************
//  Function    :   GDI_InitialRegion
//  Description :   This function prepares the region by setting the header of BMP OSD
//  Arguments   :   bRegionId: the ID of the region to initialize, 
//                             The ID is an index to the __RegionList
//  Return      :   NULL
//  Side Effect :
//  *********************************************************************

BOOL GDI_InitialRegion(BYTE bRegionId)
{
#ifndef NO_GDI


    if (bRegionId >= NUMBER_OF_REGION) 
        return FALSE;
    
    //W99AV_WriteDRAMData( W99AV_DRAM_OSDT_ADR, 0x0 );
    //W99AV_WriteDRAMData( W99AV_DRAM_OSDB_ADR, 0x0 );
#ifdef USE_ONE_OSD_REGION
    _dwGDIHeaders[0]=( HEADER0_BMP | (((DWORD) __bColorMode )<<27 ));
#else
    _dwGDIHeaders[0]=( HEADER0_BMP | (((DWORD) __RegionList[bRegionId].bColorMode )<<27 ));
#endif

    _dwGDIHeaders[1]=HEADER1_BMP;
    // write header0, header1 to DRAM
#ifdef MINI_OSD_REGION // CT908S


    // Brian2.30, use region address to judge if we are going to use the mini-osd region
    if (__dwRegionTAddr == (REGION_T_ADDR0+(GDI_REGION_WIDTH>>3)-4))
    {
        // to speed up the GXA command, use a pesudo region
        // set NEXT_OSD_ADD , Top/Down could use the same pseudo headea
        // set NEXT_OSD_ADD: [0]~[19]
        _dwGDIHeaders[0] &= 0xFFF00000;
        // don't forget we have a whole line of space (80 DW) used as "Header" area, now use the 4 DW before the TOP header as the pseudo OSD address
        _dwGDIHeaders[0] |= (__dwRegionTAddr -4); 
        // set NEXT_OSD_SIZE: [0]~[31]
        _dwGDIHeaders[1] = ((__RegionList[bRegionId].wWidth * PSEUDO_REGION_HEIGHT) >> 4) + 4; // 370 lines, 100~469

    }


    W99AV_WriteDRAMBurst(__dwRegionTAddr ,_dwGDIHeaders, 2);
    W99AV_WriteDRAMBurst(__dwRegionBAddr ,_dwGDIHeaders, 2);


    // Brian2.30, set pseudo region header, Top/Down could use the same pseudo header
    // always set this is OK even if it is not mini-OSD region
    // set NEXT_OSD_ADD: [19:0]
    _dwGDIHeaders[0] &= 0xFFF00000; // pesudo is the last, so NEXT_OSD_ADD is 0
    _dwGDIHeaders[1] = 0; // pesudo is the last, so NEXT_OSD_SIZE is 0
    W99AV_WriteDRAMBurst(__dwRegionTAddr-4 ,_dwGDIHeaders, 2);
     

#else
    W99AV_WriteDRAMBurst(__RegionList[bRegionId].dwTAddr ,_dwGDIHeaders, 2);
    W99AV_WriteDRAMBurst(__RegionList[bRegionId].dwBAddr ,_dwGDIHeaders, 2);
#endif

    //W99AV_WriteDRAMBurst(BMP_GRP_TADDR, _dwSWOSDHeaders, 2);
    //W99AV_WriteDRAMBurst(BMP_GRP_BADDR, _dwSWOSDHeaders, 2);

    // Calculate start/end pixel/line; assign header2 and header3
#ifdef H2D
    _dwGDITemp=REGION_X_NTSC+__RegionList[bRegionId].wWidth*2; // 2 means: 2 clock/pixel
#else
    _dwGDITemp=REGION_X_NTSC+__RegionList[bRegionId].wWidth*2*2; // 2 means: 2 clock/pixel
#endif

#ifdef USE_ONE_OSD_REGION
    _dwGDIHeaders[0]=( HEADER2_BMP | (((DWORD)__bColorMode)<<30) |
        (((DWORD)REGION_X_NTSC) << 12) |
        (((DWORD)_dwGDITemp) << 1) );
#else
    _dwGDIHeaders[0]=( HEADER2_BMP | (((DWORD)__RegionList[bRegionId].bColorMode)<<30) |
        (((DWORD)REGION_X_NTSC) << 12) |
        (((DWORD)_dwGDITemp) << 1) );
#endif

#ifdef MINI_OSD_REGION // CT908S
    _dwGDITemp=REGION_Y_NTSC+__dwRegionHeight/2;
#else
    _dwGDITemp=REGION_Y_NTSC+__RegionList[bRegionId].wHeight/2;
#endif

    _dwGDIHeaders[1]=( HEADER3_BMP | (((DWORD)REGION_Y_NTSC)<<9) | ((DWORD)_dwGDITemp) );

#ifdef H2D
    _dwGDIHeaders[0] = _dwGDIHeaders[0] | 0x00800000; // bit 23, H2D
#endif

    // write header2, header3 to DRAM
#ifdef MINI_OSD_REGION // CT908S
    
    W99AV_WriteDRAMBurst(__dwRegionTAddr+2, _dwGDIHeaders, 2);
    W99AV_WriteDRAMBurst(__dwRegionBAddr+2, _dwGDIHeaders, 2);


    // Brian2.30, set pseudo region header, Top/Down could use the same pseudo header
    // always set this is OK even if it is not mini-OSD region
    // set OSD_DISP to 0: [29]
    _dwGDIHeaders[0] &= 0xDFFFFFFF;
    // Set START_LINE [17:9], END_LINE [8:0]
    _dwGDIHeaders[1] &= 0xFFFC0000; 
    _dwGDITemp = (DWORD)REGION_Y_NTSC + PSEUDO_REGION_START_LINE/2 ; // start_line
    _wGDITemp = _dwGDITemp + PSEUDO_REGION_HEIGHT/2;    // end_line

⌨️ 快捷键说明

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