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

📄 stpmain.c

📁 MTK 1389E SOURCE CODE
💻 C
📖 第 1 页 / 共 5 页
字号:
/**********************************************************************/
/***************    MTK CONFIDENTIAL & COPYRIGHTED     ****************/
/***************                                       ****************/
/***************  $Modtime:: 05/11/24 11:48a   $       ****************/
/***************  $Revision:: 18               $       ****************/
/***************                                       ****************/
/***************   Description : Setup Menu            ****************/
/***************                                       ****************/
/***************       Company : MediaTek Inc.         ****************/
/***************    Programmer :                       ****************/
/**********************************************************************/

#define _SETUP_C

#include "general.h"

#include "stposdfn.h"
#include "stppass.h"
#include "stpmenu1.h"
#include "stpmain.h"
#include "../../custom/demo/fslist/flcomm.h" //0728

#define STP_STICK_DATA   0
#define STP_POPUP_DATA   1
#define SETUP_MENU_DATA_STYLE  STP_STICK_DATA

#pragma NOAREGS

#define MSG_X_IN_CENTER 0xFFFF

#define INVALID_MENU   0xFF
#define INVALID_ENTRY 0xFF
#define INVALID_DATA    0xFF

#define HEAD_MSG_X 20
#define HEAD_MSG_Y  0

#ifdef MTK_SHRINK_STP
#define DATA_LEN   204 //[runma]240 -> 220 ->212
#else
#define DATA_LEN   212 //[runma]240 -> 220 ->212
#endif
#define MSG_X_ST  10

// *********************************************************************
// Local Define
// *********************************************************************
static void vShowMenu(sMenu *prMenu) large;
static void vDrawMenu(sMenu *prMenu) large;

BOOL fgSetupState(void) large;
void vSetupInitState(void) large;

static BOOL fgMainMenuPrev(sMenu *prMenu) large;
static BOOL fgMainMenuNext(sMenu *prMenu) large;
static BOOL fgEntryPrev(sMenu *prMenu) large;
static BOOL fgEntryNext(sMenu *prMenu) large;
static void vEntryAct(void) large;
static BOOL fgDataPrev(sEntry *prEntry) large;
static BOOL fgDataNext(sEntry *prEntry) large;
//static void vItemValueCtrl(sEntry *prEntry,BOOL fgIfInc) large;

static void vCtrlDraw(BYTE bCtrlType, BYTE bIndex) large;
static BOOL fgProcCtrl(BYTE bCtrlType, sEntry *prEntry, BOOL fgInc) large;
static void vCtrlAct(void) large;
static void vCtrlMove(BYTE bCtrlType, BYTE bIndex) large;
static void vCtrlClear(BYTE bCtrlType, BYTE bIndex) large;
static void vSetItemPos(BYTE bIndex, BYTE bOffset) large;
static void vSetDataPos(BYTE bIndex, BYTE bOffset) large;
static void vCalSliderPos(BYTE bIndex) large;

static BOOL fgCalEntryShowRange(BYTE bTotalEntry, BYTE bTotalLine) large;
static BOOL fgCalDataShowRange(BYTE bTotal, BYTE bLength) large;

static void vShowRelatedMsg(sMenu *prMenu) large;
static void vShowMenuRoot(sMenu *prMenu) large;
static void vDrawMenuBtn(sMenu *prMenu, BYTE bIndex, BOOL fgEnable) large;
void vSyncInternalState(void) large;

static void vSetWbCol(void) large;

static void vDrawDialog(sMenu *prMenu) large;
static void vDialogInit(sMenu *prMenu) large;
static void vDialogDrawEntry(sMenu *prMenu) large;
static void vGetDlgParent(BYTE bDlg) large;

static void vDataInput(sMenu *prMenu) large;

static void vResetVdoQlty(void) large;

static void vEnVerMenu(void) large;

xdata BYTE _bMaxData;
xdata BYTE _bMinShowData;
xdata BYTE _bMaxShowData;
xdata BYTE _bMinShowDat;

static code BYTE _pbEnVerMenu[] = { IR_NUM1, IR_NUM3, IR_NUM8, IR_NUM9 };

#ifdef SRV_SHOW_ERROR_COUNTER
static code BYTE _SrvShowErr[] = { IR_NUM4, IR_NUM5, IR_NUM7, IR_NUM8 };

void vCheckShowErrKey(void) large;
#endif

BYTE bGetOptFromDefault(sEntry *prEntry) large
{
  BYTE  bTemp;
  BYTE  bDefVal;

  if (prEntry->wType != ENTRY_TYPE_GROUPBUTTON)
  {
    return (prEntry->wDefault);
  }

  bDefVal = prEntry->wDefault;
  for (bTemp=0; bTemp<=prEntry->wMaxOpt; bTemp++)
  {
    if (prEntry->prData[bTemp]->bVal == bDefVal)
    {
      break;
    }
  }

  return (bTemp);
}


BYTE bGetOptFromEeprom(sEntry *prEntry) large
{
  BYTE  bTemp;
  BYTE  bStoredVal;


  if (prEntry->wType != ENTRY_TYPE_GROUPBUTTON)
  {
    //if((prEntry->wType == ENTRY_TYPE_H_SLIDER_SIGNED) || (prEntry->wType == ENTRY_TYPE_H_SLIDER) ||
    if((prEntry->wType == ENTRY_TYPE_H_SLIDER_SIGNED) ||
       (bEepromReadByte(prEntry->wEEPos) <= prEntry->wMaxOpt))
    {
      return (bEepromReadByte(prEntry->wEEPos));
    }
    else if ((prEntry->wType == ENTRY_TYPE_EDITBOX) || (prEntry->wType == ENTRY_TYPE_EDITBOX_ORDERED))
    {
      return 0;
    }
    else  // (bEepromReadByte(prEntry->wEEPos) > prEntry->wMaxOpt)
    {
      return (prEntry->wDefault);
    }
  }

  bStoredVal = bEepromReadByte(prEntry->wEEPos);
  for (bTemp=0; bTemp<=prEntry->wMaxOpt; bTemp++)
  {
    if (prEntry->prData[bTemp]->bVal == bStoredVal)
    {
      break;
    }
  }
  if (bTemp > prEntry->wMaxOpt)
  {
    // not found
    bTemp = bGetOptFromDefault(prEntry);
  }
  return (bTemp);
}

// *********************************************************************
// Function : void vInitEntry(BYTE bMenuNum, BYTE bReset)
// Description :
// Parameter : None
// Return    : None
// Note      : reset should note if some function can not execute !!!
// *********************************************************************
void vInitEntry(BYTE bMenuNum, BYTE bReset) large
{
  BYTE   bTmp;
  WORD   wEEPos;
  sEntry *prEntry;
  BYTE (code *bDeal)(WORD wEEPos, BYTE bValue) large;

  for(_bEntry=1; _bEntry<=_rMenuRoot.prMenu[bMenuNum]->bTotalEntry; _bEntry++)
  {
    // if no EE entry, then no init
    prEntry = _rMenuRoot.prMenu[bMenuNum]->prEntry[_bEntry-1];


    if ((prEntry == NULL) || (prEntry->wType == ENTRY_TYPE_SUBMENU) || (prEntry->wEEPos == NULL_EE_ITEM))
    {
      continue;
    }

    switch(prEntry->wType)
    {
      case TYPE_MAINMENU:
      //case TYPE_PAGE:
      case TYPE_CLOSE:
      case ENTRY_TYPE_STATIC:
      case ENTRY_TYPE_RETURN:
      case ENTRY_TYPE_SUBMENU:
      case ENTRY_TYPE_DIALOG:
        continue;
      default:
        break;
    }

    if ((bReset == MENU_ITEM_DEFAULT) || (bReset == MENU_ITEM_INIT))
    {
      //if reset is needed, write default to EE
      if (bReset == MENU_ITEM_DEFAULT)
      {
        switch(prEntry->wEEPos)
        {
          // no reset item
          case PTL_LEVEL_POSITION:
          case REGION_CODE_POSITION:
            _bDataCur = _bDataSel = bGetOptFromEeprom(prEntry);

          case PASS_SW_POSITION:
            continue;

          default:
            break;
        }
      }
      _bDataCur = _bDataSel = bGetOptFromDefault(prEntry);
      if (prEntry->wEEPos)
      {
        fgEepromWriteByte(prEntry->wEEPos, prEntry->wDefault);
      }
    }
    else
    {
      //if init, read from EE
      //_bDataCur = _bDataSel = bEepromReadByte(prEntry->wEEPos);
      _bDataCur = _bDataSel = bGetOptFromEeprom(prEntry);
    }

    switch(prEntry->wType)
    {
      //case TYPE_SLIDE:
      case ENTRY_TYPE_STATIC:
      case ENTRY_TYPE_H_SLIDER_SIGNED: //[runma] add line
        // slide could be negative
        if (((char)_bDataCur > (BYTE)bOptMaxEntryNum(_rMenuRoot, bMenuNum, _bEntry) ||
            ((char)_bDataCur < (char)(0 - bOptMaxEntryNum(_rMenuRoot, bMenuNum, _bEntry)))))
        {
          _bDataCur = _bDataSel = bGetOptFromDefault(prEntry);
          fgEepromWriteByte(prEntry->wEEPos, _bDataCur);
        }
        break;

      default:
        if (_bDataCur > bOptMaxEntryNum(_rMenuRoot, bMenuNum, _bEntry))
        {
          _bDataCur = _bDataSel = bGetOptFromDefault(prEntry);
          fgEepromWriteByte(prEntry->wEEPos, _bDataCur);
        }
        break;
    }

    // reset should note if some function can not execute
    switch (prEntry->wEEPos)
    {
      case PTL_LEVEL_POSITION:
        //vSetSharedInfo(SI_PTL_LV, _bDataCur);
        vSystemParentalLevel(_rMenuRoot.prMenu[bMenuNum]->prEntry[_bEntry-1]->prData[_bDataCur]->bVal);
        continue;
      case REGION_CODE_POSITION:
        vSetSharedInfo(SI_REGION, bEepromReadByte(prEntry->wEEPos) << 4);
        continue;
      case AUDIO_LCD_POSITION:
      case SP_LCD_POSITION:
        if((prEntry->prData[_bDataCur]->bVal == EV_LANG_OFF))
        {
          vSystemPrefSpLang(0,0);
        }
      case MENU_LCD_POSITION:
    	if((prEntry->prData[_bDataCur]->bVal == EV_OTHER)) //[runma] add line
    	{
 	  	   switch (prEntry->wEEPos)
  	  	  {
   	  	   case AUDIO_LCD_POSITION:
       		   vSystemPrefAuLang('a'-'A'+bEepromReadByte(AUDIO_LCD_POSITION_0),
                            'a'-'A'+bEepromReadByte(AUDIO_LCD_POSITION_1));
         		 break;
        	case SP_LCD_POSITION:
         		 vSystemPrefSpLang('a'-'A'+bEepromReadByte(SP_LCD_POSITION_0),
                            'a'-'A'+bEepromReadByte(SP_LCD_POSITION_1));
          	break;
        	case MENU_LCD_POSITION:
         		 vSystemPrefMenuLang('a'-'A'+bEepromReadByte(MENU_LCD_POSITION_0),
                              'a'-'A'+bEepromReadByte(MENU_LCD_POSITION_1));
        	  	break;
      	}
      continue;
      }
//      continue;
    }

    // execute the function, item point to
    bDeal = prEntry->bFun;

    if (bDeal && (bDeal != bResetDefault) && (bDeal != bSetVdoQlty) && (bDeal != bNormalVdo)) //r /*&& (prEntry->wSIPos != SI_LUMINANCE)&& (prEntry->wSIPos != SI_SHARPNESS)*/)
    {
      if ((_fgReset == TRUE) && (_fgNotify == TRUE) && (prEntry->wSIPos != NULL_SI))
      {
        while (bSharedInfo(SI_SHI_NS) >= bSharedInfo(SI_SHI_SZ)-1);
      }

      bTmp = bDeal(prEntry->wEEPos, prEntry->prData[_bDataSel]->bVal);

      if (!_fgReset)
        vRedrawMenu(bTmp);
    }

    // call audio dsp releative routine
    vSetADsp(TRUE);

    // call video releative routine
    if(bDeal == bSetVdoQlty)
  	  bSetVdoQlty(prEntry->wEEPos, _bDataSel);
  	if (bDeal == bNormalVdo)
  	  bNormalVdo(prEntry->wEEPos, _bDataSel);

  } // End for j
}

#ifdef POWER_ON_RESET_VDO
// *********************************************************************
// Function : void vResetVdoPage(void) large
// Description :
// Parameter : None
// Return    : None
// *********************************************************************
void vResetVdoPage(void) large
{
#ifndef SIMPLE_MENU
  BYTE bTmpPage;

  bTmpPage = _bMenu;
  _bMenu = VDO_PAGE;
  vInitMenuEntry(VDO_PAGE, MENU_ITEM_DEFAULT); //[runma] DEFAULT); -> eeprom for fixing p/n tray out problem.
  _bMenu = bTmpPage;
#endif
}
#endif

// *********************************************************************
// Function : void vInitMenuEntry(BOOL fgReset) large
// Description : 1.init all item
//               2.if needed, set to factory setting
// Parameter : fgReset  - 2, set to default value, include protected item
//                      - 1, set to default value, not include protected item
//                      - 0, get from SEEPROM
// Return    : None
// *********************************************************************
void vInitMenuEntry(BYTE bReset) large
{
  // check all menu to init all entry
  for(_bMenu=0; _bMenu<MAX_PAGE; _bMenu++) //[runma] change to this. MAX_PAGE
  {
    if ((_bMenu == PASS_CHG_PAGE) || (_bMenu == PASS_CON_PAGE) ||
#if (defined(PTL_PWD_MODE_SW) || defined(SET_PTL_NEED_PWD))
        (_bMenu == PASS_PAGE))
#endif
        continue;
    vInitEntry(_bMenu, bReset);
  }  // End for i

#ifdef POWER_ON_RESET_VDO
  vResetVdoPage();
#endif
}

// *********************************************************************
// Function : void vRedrawMenu(void) large
// Description : redraw a setup menu page
// Parameter : None
// Return    : None
// *********************************************************************
void vRedrawMenu(BYTE bType) large
{
  if (!_fgNotify || _fgReset || (fgIsInSetupMenu() == FALSE))
  {
    return;
  }

  if (bType == ENTRY_FUN_OK)   // no need redraw page
  {
    return;
  }

#ifdef IR_SUPPORT_SHIFT_KEY
/*
  if ((_bOsdState == STPSTT_PASSWORD) ||
      (_bOsdState == STPSTT_CON_PSWD) ||
      (_bOsdState == STPSTT_CON_PSWD_PWD) || (_bOsdState == STPSTT_CON_PSWD_PRE))
*/
  if ((_bOsdState == STPSTT_DIALOG) && DLG_TYPE_DIGIT(_bDlgId))
  {
    // force use normal key table to input number
    vSetShiftKeyMode(FALSE);
  }
  else
  {
    // force use shift key table to use arrow key
    vSetShiftKeyMode(TRUE);
  }
#endif

  // set previous menu to invalid, then call show menu to redraw
  _bPrevMenu = INVALID_MENU;
  vShowMenu(_rMenuRoot.prMenu[_bMenu]);
}

// *********************************************************************
// Function : BYTE bAngleChange(WORD wEEPos, BYTE bValue) large
// Description : Angle mark On/Off change, show or hide angle mark
// Parameter : None
// Return    : None
// *********************************************************************
BYTE bAngleChange(WORD wEEPos, BYTE bValue) large
{
  BYTE bPbcState = bSharedInfo(SI_PBC_STATE);

#ifdef SETUP_NO_AGL_MARK
  vSetAngleShow(TRUE);    // default is show angle mark
#else
  if (bEepromReadByte(ANGLE_MARK_POSITION) == EV_ON)
  {
    vSetAngleShow(TRUE);
  }
  else
  {
    vSetAngleShow(FALSE);
  }
#endif

  if (!_fgNotify)
  {
    return (ENTRY_FUN_OK);
  }

  if ((!fgIsNonPlay()) && fgIsDiscPlay(bPbcState))
  {
    if (fgIsAngleShow())
    {
      vOsdShowAngle(OSD_ANGLE_NORMAL, bSharedInfo(SI_AGL_NO), bSharedInfo(SI_AGL_NS));
    }
    else
    {
      vOsdShowAngle(OSD_ANGLE_CLEAR, 0, 0);
    }
  }

  return (ENTRY_FUN_OK);
}

static void vSetNewMenu(BYTE bNewMenu) large
{
  _bPrevItem = INVALID_ENTRY;
  _bMenu = bNewMenu;
  _bEntry = 1;
  _bOsdState = STPSTT_ENTRY;
}

static void vSetWbCol(void) large

⌨️ 快捷键说明

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