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

📄 gdi_main.c

📁 Gui of OSD programming
💻 C
📖 第 1 页 / 共 4 页
字号:
 * @return  --
 *
 ******************************************************************************/

void GDI_Drcs1Compress(const uint8_t lines)
{
   if (lines == LINES_9)
   {
      GlobalDisplayWord[6] &= 0xFE;                      /* set bit 0 to '0' */
      /* combined ROM and DRCS1 characters */
      API_Tvt_Mx3Decompress((uint8_t*)srcDrcs1, fontDrcs1, LINES_9);
      linesPerCharacter = LINES_9;
   }
   else if (lines == LINES_10)
   {
   /* GlobalDisplayWord[6] &= 0xC0; */              /* reset resolution bits */
      GlobalDisplayWord[6] &= 0x40;                 /* reset resolution bits */
      GlobalDisplayWord[6] |= 0x09;/* set bit 0/3 to '1': resolution 10lines */
      /* combined ROM and DRCS1 characters */
      API_Tvt_Mx3Decompress((uint8_t*)srcDrcs1, fontDrcs1, LINES_10);
      linesPerCharacter = LINES_10;
   }
}



/******************************************************************************/
/**
 * @brief   Loads DRCS1 characters depending in vertical frequency.
 *
 * @param   --
 *
 * @return  --
 ******************************************************************************/

void GDI_LoadDrcs1(void)
{
   if (isTvMode50Hz_g == SYS_TRUE)
   {
      if (linesPerCharacter == LINES_9)
         GDI_Drcs1Compress(LINES_10);             /* set 10-lines-characters */
   }
   else
   {
      if (linesPerCharacter == LINES_10)
         GDI_Drcs1Compress(LINES_9);               /* set 9-lines-characters */
   }
}


/******************************************************************************/
/**
 * CODE ARRAY for colour replacement of DRCS4 characters.
 * Attention: Bit order per nibble = bit0, bit1, bit2, bit3
 ******************************************************************************/

uint8_t code exArraySelected[2][2] = { /* 3->8, 4->8, 5->9, 6->10, 7->11 */
   {0x03,0x07},
   {0x0B,0x0F},
//   {0x0A,0x09},
//   {0x06,0x05},
//   {0x0E,0x0D}
};

uint8_t code exArrayActive[2][2] = { /* 1->12, 4->12 */
    {0x03,0x0F},//kent_20060309_test  {0x08,0x03},
   {0x0B,0x07}//kent_20060309_test{0x02,0x03}
};



/******************************************************************************/
/**
 * @brief   Replaces subclut information of a DRCS4 character according to
 *          the given exchange array.
 *
 * @param   charAddr  [in]  Address of character to be changed
 * @param   mode      [in]
 *
 * @return  --
 ******************************************************************************/

void GDI_ReplaceSubclutDrcs4(const uint16_t charAddr, const uint8_t mode)
{
   uint8_t xdata *addrDrcs4;
   uint8_t latch;
   uint8_t nibleftIn, nibrightIn, nibleftOut, nibrightOut;
   uint8_t  j, k;
   uint16_t i;  //kent_20060316

   /* pointer to first char byte */
   addrDrcs4 = (uint8_t*)((uint16_t)((charAddr-DRCS4_BORDER)*60+DRCS4_ADDRESS));

   for (i = 0; i < 720; i++)     /* 1 DRCS4 char has 60 bytes, 4 chars = 240 */
   {
      latch = *addrDrcs4;                              /* get character byte */
      nibleftIn = latch >> 4;                             /* get left nibble */
      nibrightIn = latch & 0x0F;                         /* get right nibble */
      nibleftOut = nibleftIn;            /* just in case no exchange is done */
      nibrightOut = nibrightIn;
      k = 2;                      /* assume mode is ACTIVE, change 2 colours */

      if (mode == BIGICON_SELECTED)
         k = 2;                   /* 5 colours to change if mode is SELECTED */
      /* replace colours */
      for (j = 0; j < k; j++)
      {
         if (mode == BIGICON_ACTIVE)
         {
            if (nibleftIn == exArrayActive[j][0])
               nibleftOut = exArrayActive[j][1];
            if (nibrightIn == exArrayActive[j][0])
               nibrightOut = exArrayActive[j][1];
         }
         else
         {
            if (nibleftIn == exArraySelected[j][0])
               nibleftOut = exArraySelected[j][1];
            if (nibrightIn == exArraySelected[j][0])
               nibrightOut = exArraySelected[j][1];
         }
      }
      latch = nibleftOut << 4 | nibrightOut;
      *addrDrcs4 = latch;
      addrDrcs4++;
   }
}



/******************************************************************************/
/**
 * @brief   Shows edit mode change by highlighting item area
 *
 * @param   editMode: SYS_TRUE, SYS_FALSE
 *
 * @return  --
 ******************************************************************************/

void GDI_ShowEditModeChange(const bool_t editMode)
{
   uint8_t redh, greenh, blueh, red0, green0, blue0;
   uint8_t i;

   if (editMode == prevEditMode)
      return;

   red0 = Clut2[11] & 0x0F;
   green0 = Clut2[10] >> 4;
   blue0 = Clut2[10] & 0x0F;

   if (editMode == SYS_TRUE)
   {
      redh = (2 * red0) + 8;

      if (redh > 15)
         redh = 15;

      greenh = (2 * green0) + 8;

      if (greenh > 15)
         greenh = 15;

      blueh = (2 * blue0) + 8;

      if (blueh > 15)
         blueh = 15;
      Clut2[10] = greenh << 4 | blueh;
      Clut2[11] = 0x10 | redh;
      Clut2[58] = greenh << 4 | blueh;
      Clut2[59] = 0x10 | redh;
      CTRL_Wait(60);

      for (i = 0; i < 8; i++)
      {
         if (redh > 2 * red0)
            redh -= 1;
         if (greenh > 2 * green0)
            greenh -= 1;
         if (blueh > 2 * blue0)
            blueh -= 1;

         Clut2[10] = greenh << 4 | blueh;
         Clut2[11] = 0x10 | redh;
         Clut2[58] = greenh << 4 | blueh;
         Clut2[59] = 0x10 | redh;
         CTRL_Wait(20);
      }
   }
   else
   {
      Clut2[10] = (green0 / 2) << 4 | (blue0 / 2);
      Clut2[11] = 0x10 | (red0 / 2);
      Clut2[58] = (green0 / 2) << 4 | (blue0 / 2);
      Clut2[59] = 0x10 | (red0 / 2);
   }
   prevEditMode = editMode;
}



/******************************************************************************/
/**
 * @brief   Bans a rectangle from any update-action (e.g. in teletext mode).
 *
 * @param   state   [in] SYS_ON or SYS_OFF
 *
 * @return  --
 ******************************************************************************/

#if __TTX_CONFIG__ != NO_TTX
void GDI_BanRectangle(const offOn_t state)
{
   uint8_t length = rectangle_g.StopCol - rectangle_g.StartCol + 1;

   activeRow_g = rectangle_g.StartRow;
   if (state == SYS_ON)
   {
      while (activeRow_g <= rectangle_g.StopRow)
      {
         SetInhibitUpdateBits(activeRow_g * 40 + rectangle_g.StartCol, length);
         activeRow_g++;
      }
   }
   else
   {
      while (activeRow_g <= rectangle_g.StopRow)
      {
         ClearInhibitUpdateBits(activeRow_g*40 + rectangle_g.StartCol, length);
         activeRow_g++;
      }
   }
}
#endif



/******************************************************************************/
/**
 * @brief   Switches off and on the XRam font. Saves old language and restores
 *          it later. Function is used to switch to standard Rom font for some
 *          routines, which are not allowed (or possible) with RAM fonts.
 *
 * @param   mode [in]  SYS_ON:  deactivate XRam font
 *                     SYS_OFF: restore XRam font
 *
 * @return  --
 ******************************************************************************/

#ifdef __X_RAM__
void GDI_DeactivateXRamFont(const uint8_t mode)
{
   if (mode == SYS_ON)
   {
      /* deactivate RAM-font, switch to ROM-font and English language */
      if (xRamLanguage_g == SYS_TRUE)
      {
         activeXRamFont = SYS_TRUE;
         xRamLanguage_g = SYS_FALSE;
         language = osdLanguage_g;
         osdLanguage_g = STRG_ENGLISH;
         CORE_SwitchToRomFont();
         OSD_CTRL |= 0x0D;      /* enable OSD */
      }
      else
      {
         activeXRamFont = SYS_FALSE;
      }
   }
   else
   {
      /* restore original language (RAM-font) */
      if (activeXRamFont == SYS_TRUE)
      {
         osdLanguage_g = language;
         CORE_SwitchToXRamFont();
         xRamLanguage_g = SYS_TRUE;
         OSD_CTRL |= 0x0D;      /* enable OSD */
      }
   }
}
#endif


/******************************************************************************/
/**
 * @brief   Calculation of the Bitmap position, depends on OSD position
 *
 * @param   --
 *
 * @return  --
 ******************************************************************************/
#ifdef __ENABLE_BITMAP_ICONS__
void GDI_Calculate_Bmp_Position(void)
{
   /* set GRHORPOS = Horizontal Position and GRVERPOS = Vertical Position  */
#if __BE_CONFIG__  == VCTP_BE_CRT
     API_Vid_SetBmpWindowPos(BMP_WINDOW1_POS, 
                             (SDH0 * (PIXEL_REPITITION + 1)) + 139, 
                             SDV0 + 11);
#else
     API_Vid_SetBmpWindowPos(BMP_WINDOW1_POS, 
                             (SDH0 * (PIXEL_REPITITION + 1)) + 139, 
                             SDV0 + 31);
#endif
}
#endif



/******************************************************************************/
/**
 * @brief   Initiailisation of the TVTEXT PRO sepcial function registers for
 *          display chapter, VBI-buffer, display position and modes.
 *
 * @param   --
 *
 * @return  --
 ******************************************************************************/

void GDI_sfrinit(void) small
{

   SDH0 = GDI_GetSdh();                 /* horizontal position; lowbyte  */
   SDV0 = GDI_GetSdv();                 /* vertical position; lowbyte    */

#if defined __ENABLE_BITMAP_ICONS__
   GDI_Calculate_Bmp_Position();
#endif

   SDH1 = 0;                            /* horizontal position; highbyte */
   SDV1 = 0;                            /* vertical position; highbyte   */

/* arzdorf: removed following CRT part, PIxel repetition replaced by 
            PIXELDOUBLER, see PIXEL_REPITITION */

/* #if __BE_CONFIG__ == VCTP_BE_CRT */      /* chinaburger1 */
/*   PIX_REP_POS0 = 0x01;  */               /* scale width */
/* #else */
   PIX_REP_POS0 = 0x00;                 /* horizontal scaling            */
/* #endif   */


   EHCR  = 0x00;
   BHCR  = 0x00;

   SCR0  = 0x00;
   SCR1  = 0x00;

   BVCR1 = 0x00;
   BVCR0 = 0x00;
   EVCR1 = 0x00;
   EVCR0 = 0x00;

   VLR1  = 0x01;

   /* enable OSD */
   OSD_CTRL |= 0x6c;

#ifdef DEBUG_IN_OSD
   SDV0  = 2+40;   /* fix position on screen in debug mode */

   L24 = 0;
   IEN3 |= IEN3_E24;
   EAL = 1;
#endif


#if __TTX_CONFIG__ != NO_TTX
   SetInhibitUpdateBits(1, 2);
#endif

   GDI_SetGdw(GDW_INIT);
   CORE_InitRamAdressRegisters();          /* init the ram address registers */

#if __TTX_CONFIG__ != NO_TTX
   /* determine the absolute conversion start address for the TDC */
   TdcParameters.ConversionDestination = (uint16_t)&DisplayBuffer[0];
#endif
}


/******************************************************************************/
/**
 * @brief   replacement for firmware function if no text.
 *
 * @param   --
 *
 * @return  --
 ******************************************************************************/

#if ( __TTX_CONFIG__ == NO_TTX )
void osd(void) small
{
   RETURN_3 ^= 0x10;
}
#endif



#if __BE_CONFIG__ == VCTP_BE_CRT
/* chinaburger_beg */
/******************************************************************************/
/**
 * @brief   Set PROGRESS bit
 *
 * @param   0 or 1
 *
 * @return  --
 ******************************************************************************/

void GDI_SetProgressive(bool_t onOff)
{
   if (onOff == SYS_FALSE)
   {
      GlobalDisplayWord[0] &= 0xDF;
   }
   else
   {
      GlobalDisplayWord[0] |= 0x20;
   }
}

/* chinaburger_end */
#endif


/******************************************************************************
 *
 * LOCAL FUNCTIONS:
 ******************************************************************************/

/******************************************************************************/
/**
 * @brief   Translates the display addressing from row/column format to
 *          binary format.
 *
 * @param   --
 *
 * @return  buffer position
 ******************************************************************************/

static uint16_t BufferPosition(void)
{
   return (3 * ((int16_t)(activeRow_g * NUM_COLS) + activeCol_g));
}

⌨️ 快捷键说明

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