?? gdi_main.c
字號:
/******************************************************************************/
/**
* @file gdi_main.c
*
* @brief This module contains the low level functions of the Graphic Device
* Interface (GDI)
*
* @note (c) 2001 - 2003 Micronas GmbH. All rights reserved.
* Any use of the Software is permitted only in accordance
* with the terms set forth in the Disclaimer text file.
*
* @author ACOM software team
******************************************************************************/
#define _SOURCE_GDI_MAIN_
/******************************************************************************
*
* INCLUDE FILES
******************************************************************************/
#include <system.h>
#include <ctrl_main.h>
#include <api_i2c.h>
#include <core_main.h>
#ifdef __DEMO_LOOP__
#include <demo_loop.h>
#endif
#include <mnu_main.h>
#include <gdi_main.h>
#include <ctrl_msgparse.h>
#include <pref_main.h>
#ifdef __RADIO_MODE__
#include <radio_main.h>
#endif
#include <core_ramset.h>
#include <main_special.h>
#include <gdi_strings.h>
#if ( __TTX_CONFIG__ != NO_TTX )
#include <ttxfirmware.h>
#include <text_main.h>
#endif
#include <api_vid.h>
#include <mnu_view.h>
#ifdef __CAPTION__
#include <CC_Decoder_Config.h>
#include <CC_Decoder_Interface.h>
#endif
#ifdef __VCHIP__
#include <vchip_main.h>
#endif
#if defined __ENABLE_BITMAP_ICONS__
#include <vctp_vid_init.h>
#endif
/******************************************************************************
*
* LOCAL FUNCTION PROTOTYPES:
******************************************************************************/
static uint16_t BufferPosition(void);
/******************************************************************************
*
* LOCAL VARIABLES:
******************************************************************************/
static uint8_t linesPerCharacter;
static bool_t prevEditMode;
#ifdef __X_RAM__
static uint8_t language;
static uint8_t activeXRamFont;
#endif
/******************************************************************************
*
* GLOBAL FUNCTIONS:
******************************************************************************/
/******************************************************************************/
/**
* @brief Sets default attributes to struct cdw_g (no modification
* of activeCol_g/activeRow_g)
*
* @param mode [in] OSD_TV, OSD_SERVICE, OSD_TELETEXT, CLEAR_SCREEN
*
* @return --
******************************************************************************/
void GDI_SetCdwAttrDefaults(const uint8_t mode)
{
cdw_g.bFlash = SYS_FALSE;
cdw_g.bUpperHalf = SYS_FALSE;
cdw_g.bDoubleHeight = SYS_FALSE;
cdw_g.bDoubleWidth = SYS_FALSE;
cdw_g.bBoxControl = BOX0;
cdw_g.bBgColor = 0;
switch (mode)
{
case OSD_TV:
cdw_g.bClutSelect = SUBCLUT2;
cdw_g.bFgColor = 3;
break;
case OSD_SERVICE:
cdw_g.bClutSelect = 0;
cdw_g.bFgColor = 7;
break;
case OSD_TELETEXT:
cdw_g.bClutSelect = 0;
cdw_g.bFgColor = 1;
break;
case CLEAR_SCREEN:
cdw_g.bClutSelect = 2;
cdw_g.bFgColor = 0;
break;
}
}
/******************************************************************************/
/**
* @brief Writes attributes to position activeRow_g, activeCol_g in
* DisplayBuffer (no modification of activeRow_g/activeCol_g).
*
* @param --
*
* @return --
******************************************************************************/
void GDI_WriteCdwAttributes(void)
{
uint8_t abCdw[3]; /* Cdw bytes 0-2, byte 0 not used in this function */
/* write only if position in display range: */
if (activeRow_g < 25 && activeCol_g < 40)
{
/* Cdw byte 1 */
abCdw[1] = DisplayBuffer[(uint16_t)(BufferPosition() + 1)];
abCdw[1] &= 0x03;
abCdw[1] |= (uint8_t)cdw_g.bFlash << 2;
abCdw[1] |= (uint8_t)cdw_g.bUpperHalf << 3;
abCdw[1] |= (uint8_t)cdw_g.bDoubleHeight << 4;
abCdw[1] |= (uint8_t)cdw_g.bDoubleWidth << 5;
abCdw[1] |= cdw_g.bBoxControl << 6;
abCdw[1] |= cdw_g.bClutSelect << 7;
/* Cdw byte 2 */
abCdw[2] = 0;
abCdw[2] |= cdw_g.bClutSelect >> 1;
abCdw[2] |= cdw_g.bFgColor << 2;
abCdw[2] |= cdw_g.bBgColor << 5;
/* if double height or width, then set upper half.
Lower half is done later: */
if (cdw_g.bDoubleHeight == SYS_TRUE)
abCdw[1] |= 0x18; /* set double hight + upper half */
if (cdw_g.bDoubleWidth == SYS_TRUE)
abCdw[1] |= 0x20; /* set double width */
/* write Cdw byte 1+2 */
DisplayBuffer[(uint16_t)(BufferPosition() + 1)] = abCdw[1];
DisplayBuffer[(uint16_t)(BufferPosition() + 2)] = abCdw[2];
/* check if double hight, if yes: write character twice one row below */
if (cdw_g.bDoubleHeight == SYS_TRUE)
{
activeRow_g++;
abCdw[1] &= 0xF7; /* delete upper half bit */
if (cdw_g.bDoubleWidth == SYS_TRUE)
abCdw[1] |= 0x20; /* set double width */
DisplayBuffer[(uint16_t)(BufferPosition() + 1)] = abCdw[1];
DisplayBuffer[(uint16_t)(BufferPosition() + 2)] = abCdw[2];
activeRow_g--;
}
}
}
/******************************************************************************/
/**
* @brief Reads attributes at position activeRow_g, activeCol_g and fills
* gstCharDipsAttr (no modification of activeRow_g/activeCol_g).
*
* @param --
*
* @return --
******************************************************************************/
#ifdef __X_RAM__
void GDI_ReadCdwAttributes(void)
{
uint8_t cdw[2]; /* Cdw bytes 0-2, byte 0 not used in this function */
/* read only if position is in display range: */
if (activeRow_g < 25 && activeCol_g < 40)
{
/* Cdw byte 1 */
cdw[0] = DisplayBuffer[(uint16_t)(BufferPosition() + 1)];
cdw_g.bFlash = (cdw[0] >> 2) & 1;
cdw_g.bUpperHalf = (cdw[0] >> 3) & 1;
cdw_g.bDoubleHeight = (cdw[0] >> 4) & 1;
cdw_g.bDoubleWidth = (cdw[0] >> 5) & 1;
cdw_g.bBoxControl = (cdw[0] >> 6) & 1;
cdw_g.bClutSelect = (cdw[0] >> 7) & 1;
/* Cdw byte 2 */
cdw[1] = DisplayBuffer[(uint16_t)(BufferPosition() + 2)];
cdw_g.bClutSelect |= (cdw[1] << 1) & 7;
cdw_g.bFgColor = (cdw[1] >> 2) & 7;
cdw_g.bBgColor = (cdw[1] >> 5) & 7;
}
}
#endif
/******************************************************************************/
/**
* @brief Writes foreground attributes into the DisplayBuffer beginning with
* position activeRow_g, activeCol_g for a defined number.
* No change of activeCol_g/activeRow_g considering values at the end
* of function.
*
* @param length [in]
*
* @return --
******************************************************************************/
void GDI_WriteCdwFgColorLength(const uint8_t length)
{
uint8_t cdwByte2;
uint8_t colStart = activeCol_g;
/* write only if position is in display range: */
if (activeRow_g < 25 && activeCol_g < 40)
{
for (; activeCol_g < (colStart + length); activeCol_g++)
{
cdwByte2 = DisplayBuffer[(uint16_t)(BufferPosition() + 2)];
cdwByte2 &= 0xE3;
cdwByte2 |= cdw_g.bFgColor << 2;
DisplayBuffer[(uint16_t)(BufferPosition() + 2)] = cdwByte2;
}
activeCol_g = colStart;
}
}
/******************************************************************************/
/**
* @brief Writes background attributes into the display-buffer beginning with
* position activeRow_g, activeCol_g for a defined number.
* No change of activeCol_g/activeRow_g considering values at the end
* of function.
*
* @param length [in]
*
* @return --
******************************************************************************/
void GDI_WriteCdwBgColorLength(const uint8_t length)
{
uint8_t cdwByte2;
uint8_t colStart = activeCol_g;
/* write only if position is in display range: */
if (activeRow_g < 25 && activeCol_g < 40)
{
for (; activeCol_g < (colStart + length); activeCol_g++)
{
cdwByte2 = DisplayBuffer[(uint16_t)(BufferPosition() + 2)];
cdwByte2 &= 0x1F;
cdwByte2 |= cdw_g.bBgColor << 5;
DisplayBuffer[(uint16_t)(BufferPosition() + 2)] = cdwByte2;
}
activeCol_g = colStart;
}
}
/******************************************************************************/
/**
* @brief Writes colour attributes (foreground, background and sub-clut)
* into the DisplayBuffer beginning with position activeRow_g,
* activeCol_g for a defined number (input-parameter).
* No change of activeCol_g/activeRow_g considering values at the end
* of function.
*
* @param length [in]
*
* @return --
******************************************************************************/
void GDI_WriteCdwColourLength(const uint8_t length)
{
uint8_t cdwByte;
uint8_t colStart = activeCol_g;
/* write only if position is in display range: */
if (activeRow_g < 25 && activeCol_g < 40)
{
for (; activeCol_g < (colStart + length); activeCol_g++)
{
cdwByte = DisplayBuffer[(uint16_t)(BufferPosition() + 1)];
cdwByte &= 0x7F;
/* set lower part of sub-clut: */
cdwByte |= cdw_g.bClutSelect << 7;
DisplayBuffer[(uint16_t)(BufferPosition() + 1)] = cdwByte;
cdwByte = 0;
/* set higher part of sub-clut: */
cdwByte |= cdw_g.bClutSelect >> 1;
cdwByte |= cdw_g.bFgColor << 2; /* set foreground colour */
cdwByte |= cdw_g.bBgColor << 5; /* set background colour */
DisplayBuffer[(uint16_t)(BufferPosition() + 2)] = cdwByte;
}
activeCol_g = colStart;
}
}
/******************************************************************************/
/**
* @brief Writes all attributes into the DisplayBuffer beginning with
* position activeRow_g, activeCol_g for a defined number.
* No change of activeCol_g/activeRow_g considering values at the end
* of function.
*
* @param length [in]
*
* @return --
******************************************************************************/
void GDI_WriteCdwAttrLength(const uint8_t length)
{
uint8_t colStart = activeCol_g;
/* write only if position is in display range: */
if (activeRow_g < 25 && activeCol_g < 40)
{
for (; activeCol_g < (colStart + length); activeCol_g++)
{
GDI_WriteCdwAttributes();
}
activeCol_g = colStart;
}
}
/******************************************************************************/
/**
* @brief Writes one character to the position activeRow_g, activeCol_g into
* the DisplayBuffer. No change of activeCol_g/activeRow_g.
*
* @param outChar [in]
*
* @return --
******************************************************************************/
void GDI_WriteCdwCharacter(uint16_t outChar)
{
uint8_t cdw[2]; /* Cdw bytes 0+1, bits 0-9 used */
#ifdef __X_RAM__
if (xRamLanguage_g && outChar >= DRCS1_BORDER && outChar < DRCS2_BORDER)
{
outChar -= DRCS1_OFFSET;
cdw_g.bDoubleHeight = SYS_FALSE; /* draw DRCS1 always as single high chars */
}
#endif
/* write only if position is in display range */
if (activeRow_g < 25 && activeCol_g < 40)
{
cdw[0] = LOBYTE(outChar); /* Cdw byte 0 */
cdw[1] = DisplayBuffer[(uint16_t)(BufferPosition() + 1)]; /* Cdw byte 1 */
cdw[1] = cdw[1] & 0xFC | (HIBYTE(outChar) & 0x03);
#ifdef __X_RAM__
/* latin character inside of XRAM string and not yet DH */
if (trueXRam_g && outChar > 0 && outChar < 0x60 && ((cdw[1] & 0x18) == 0))
{
/* draw latin characters inside XRAM as DH */
cdw_g.bDoubleHeight = SYS_TRUE;
}
#endif
/* if double height or double width, then set upper half.
Lower half is done later */
if (cdw_g.bDoubleHeight == SYS_TRUE)
cdw[1] |= 0x18; /* set double height + upper half */
if (cdw_g.bDoubleWidth == SYS_TRUE)
cdw[1] |= 0x20; /* set double width */
DisplayBuffer[(uint16_t)(BufferPosition())] = cdw[0]; /* write Cdw bytes 0+1 */
DisplayBuffer[(uint16_t)(BufferPosition() + 1)] = cdw[1];
/* check if double height, if yes, write character twice one row below */
if (cdw_g.bDoubleHeight == SYS_TRUE)
{
activeRow_g++;
cdw[1] &= 0xF7; /* delete upper half bit */
if (cdw_g.bDoubleWidth == SYS_TRUE)
cdw[1] |= 0x20; /* set double width */
DisplayBuffer[(uint16_t)(BufferPosition())] = cdw[0]; /* write Cdw bytes 0+1 */
DisplayBuffer[(uint16_t)(BufferPosition() + 1)] = cdw[1];
activeRow_g--;
}
else
{
/* write space following character for double width */
if (cdw_g.bDoubleWidth == SYS_TRUE)
{
activeCol_g++;
DisplayBuffer[(uint16_t)(BufferPosition())] = 0; /* write Cdw bytes 0+1 */
/* reset address + DH,UH */
DisplayBuffer[(uint16_t)(BufferPosition() + 1)] = cdw[1] & 0xC4;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -