prog.c

来自「代码有点长,需细心阅读,仅供影音视听类产品的开发人员参考」· C语言 代码 · 共 474 行

C
474
字号

#include "global.h"
#include "osd.h"
#include "func.h"
#include "ircmd.h"
#include "cchar.h"
#include "cfont.h"
#include "stdlib.h"

//--------DEBUG MESSAGE--------//
//#define MONE_PROG

BYTE    c_pos;
BYTE    prog_page_action;
BYTE    go_up_ok = 1;                       //Tony added 020426//1: go up ok
BYTE    go_down_ok = 1;                 //Tony added 020426//1: go down ok

/*
** prog_func_up
*/
void prog_func_up(void)
{
    BYTE    t_indx;
    BYTE    i;
    UINT16  temp;

    if(cd_type_loaded == CDROM)
        temp = file_in_dir + 1;
    else
        temp = cd_trk_hi;

    if(go_up_ok == 0)
        return;
    else
        go_down_ok = 1;

    if(c_pos > 1)
    {

        c_pos--;                                        //at least one inputted item

        t_indx = (c_pos + MAX_LINE - 1) % MAX_LINE + 1;
        t_indx += 2;                                //added two regions
        if(t_indx == MAX_LINE + 2)
        {

            for(i = 1 + 2; i <= MAX_LINE + 2; i++)  //across page,update new page
            {
                //title number
                psprintf(RegionValStr[i], "%02d", c_pos - MAX_LINE + i - 2);
                PrintOsdMsg(STR_OS_NULL, i | SW_REGION1, 0, 1, CH_N);
                //program item
                psprintf(RegionValStr[i], "%02d", prog[c_pos - MAX_LINE + i - 1 - 2]);
                PrintOsdMsg(STR_OS_NULL, i | SW_REGION3, 0, 1, CH_N);
            }
            PrintOsdMsg(STR_OS_SPACE, (1 + 2) | SW_REGION2, 0, 0, CH_N);
            PrintOsdMsg(STR_OS_ARROW, (MAX_LINE + 2) | SW_REGION2, 0, 0, CH_N);
        }
        else
        {
            PrintOsdMsg(STR_OS_ARROW, t_indx | SW_REGION2, 0, 0, CH_N);
            PrintOsdMsg(STR_OS_SPACE, (t_indx + 1) | SW_REGION2, 0, 0, CH_N);
        }
    }

#ifdef MONE_PROG
    psprintf(linebuf, "c_pos:%x t_indx:%x\n", c_pos, t_indx);
    epp_write(linebuf);
#endif
}

/*
** prog_func_down
*/
void prog_func_down(void)
{
    BYTE    t_indx;
    BYTE    i;
    UINT16  temp;

    if(go_down_ok == 0)
    {
        return;
    }
    if(cd_type_loaded == CDROM)
        temp = file_in_dir + 1;
    else
        temp = cd_trk_hi;

    if(c_pos >= PROG_NO_MAX)            //the last one can not go to the next
        return;
    //psprintf(linebuf,"t_indx:%d c_pos:%d ProgCnt:%d \n\r",t_indx,c_pos,ProgCnt);
    //epp_write(linebuf);                       
    if(c_pos <= ProgCnt)
    {
        c_pos++;
        t_indx = (c_pos + MAX_LINE - 1) % MAX_LINE + 1;
        t_indx += 2;                                //added two regions
        if(t_indx == 1 + 2)
        {
            for(i = 0 + 2; i < MAX_LINE + 2; i++)   //across page,update new page
            {
                //title number
                psprintf(RegionValStr[i + 1], "%02d", c_pos + i - 2);
                PrintOsdMsg(STR_OS_NULL, (i + 1) | SW_REGION1, 0, 1, CH_N);
                //program item
                if((c_pos + i - 2) <= ProgCnt && prog[c_pos + i - 1 - 2] != 0)
                {
                    psprintf(RegionValStr[i + 1], "%02d", prog[c_pos + i - 1 - 2]);
                    PrintOsdMsg(STR_OS_NULL, (i + 1) | SW_REGION3, 0, 1, CH_N);
                }
                else
                    PrintOsdMsg(STR_OS_DDASH, (i + 1) | SW_REGION3, 0, 0, CH_N);
            }
            PrintOsdMsg(STR_OS_ARROW, (1 + 2) | SW_REGION2, 0, 0, CH_N);
            PrintOsdMsg(STR_OS_SPACE, (MAX_LINE + 2) | SW_REGION2, 0, 0, CH_N);
        }
        else
        {
            if(c_pos - 1 <= ProgCnt)
            {
                PrintOsdMsg(STR_OS_SPACE, (t_indx - 1) | SW_REGION2, 0, 0, CH_N);
                PrintOsdMsg(STR_OS_ARROW, t_indx | SW_REGION2, 0, 0, CH_N);
            }
        }
    }

#ifdef MONE_PROG
    psprintf(linebuf, "PG:%x c_pos:%x t_indx:%x\n", ProgCnt, c_pos, t_indx);
    epp_write(linebuf);
#endif
}

/*
** prog_func_clear
*/
void prog_func_clear(void)
{
    BYTE    t_indx = 0;
    BYTE    i;

    //move all the rest items ahead one
    for(i = c_pos; i <= ProgCnt; i++)
        prog[i - 2] = prog[i - 1];
    ProgCnt--;
    //update page

    t_indx = (t_indx + MAX_LINE - 1) % MAX_LINE + 1;

    for(i = t_indx; i <= MAX_LINE; i++)
    {
        psprintf(RegionValStr[i], "%03d", prog[c_pos + i - t_indx - 1]);
        PrintOsdMsg(STR_OS_NULL, i | SW_REGION3, 0, 1, CH_N);
    }
}

/*
** prog_func_input
*/
void prog_func_input(BYTE num)
{
    BYTE    t_indx = 0;                     //stands for the location index, from 1 to 5, of programming OSD

    //index 1 is at the location of region2, index 2 is at the location of region3...
    BYTE    p10;
    UINT16  temp;                                   // (# of songs)+1
#ifdef DIGITAL_DIRECT_SELECT
    BYTE digi_limit; 
#endif
    if(delay_flag > 0)                      // delay_flage>0 means that it is showing "hand"
        return;

    //calculate # of songs
    if(cd_type_loaded == CDROM) {
        //temp = file_in_dir + 1;
        if(Gmem.gmp3.iso9660_file_cnt > 99)
           temp = 100;	
        else
           temp = Gmem.gmp3.iso9660_file_cnt + 1;   //ZHX 110203 Modified mp3 prog
    	}
    else if(cd_type_loaded == CDDA) //charles 2002/5/20 
        temp = cd_trk_hi + 1;              
    else
        temp = cd_trk_hi;
#ifdef DIGITAL_DIRECT_SELECT
    digi_limit = temp/10;
    //if(digi_limit >= num && num)
    //    num = 10;
    if(num && (digi_limit>= num) && !direct_prog) { 
        t_indx = (c_pos + MAX_LINE - 1) % MAX_LINE + 1;
        psprintf(RegionValStr[t_indx + 2], "_%d", num);
        PrintOsdMsg(STR_OS_SPACE, (t_indx + 2) | SW_REGION3, 1, 0, CH_N);
        PrintOsdMsg(STR_OS_NULL, (t_indx + 2) | SW_REGION3, 0, 1, CH_N);
        PrintOsdMsg(STR_OS_SPACE, (t_indx + 2) | SW_REGION2, 0, 0, CH_N);
        PrintOsdMsg(STR_OS_ARROW, (t_indx + 2) | SW_REGION2, 0, 0, CH_N);
        direct_prog = 1;
        direct_time = 0xff;
        prog_digital = num;
        return;
    }
    else if(direct_prog && direct_time)
    	ir_select_number = prog_digital *10;
#endif
    if((num == 10)||(num == 11))    //ZHX 081903 10+ or 5+
    {
        p10 = 1;
        if(num==11)                 //ZHX 081903
#ifdef P3_IN_P5
          ir_select_number += 3;   
#else
          ir_select_number += 5;  
#endif
        else
        	ir_select_number +=10;
        prog[c_pos - 1] = ir_select_number;
    }
    else
    {
        p10 = 0;
        if(num == 0)                                // user was pressing 0/10
        {
            if(ir_select_number > 0)    // previous is 10+
                ir_select_number += num;
            else
                ir_select_number = 10;
        }
        else
            ir_select_number += num;
        prog[c_pos - 1] = ir_select_number;
        ir_select_number = 0;               //clear for next input    
#ifdef DIGITAL_DIRECT_SELECT
        direct_prog = 0;
        direct_time = 0;
        prog_digital = 0;
#endif
    }

    t_indx = (c_pos + MAX_LINE - 1) % MAX_LINE + 1;

    if(c_pos - 1 == ProgCnt)            //new an item
    {
#ifdef MONE_PROG
        epp_write("new added item \n");
#endif

#if 0                                                       //move to below line
        //move to next page or next item
        if(t_indx == MAX_LINE && p10 == 0)  //page change ready
            prog_page_action |= PAGE_CHG_RDY;
        else
        {
#ifdef MONE_PROG
            epp_write("item change ready \n");
#endif
            prog_page_action |= ARR_MOV_RDY;
        }
#endif

        if(prog[c_pos - 1] < temp)  // the max song_number is temp-1
        {
            if(p10 == 1)
                //psprintf(RegionValStr[t_indx + 2], "%-02d", prog[c_pos - 1] / 10);
              psprintf(RegionValStr[t_indx + 2], "%02d+", prog[c_pos - 1] );
            else
                psprintf(RegionValStr[t_indx + 2], "%02d", prog[c_pos - 1]);
            PrintOsdMsg(STR_OS_SPACE, (t_indx + 2) | SW_REGION3, 1, 0, CH_N);
            PrintOsdMsg(STR_OS_NULL, (t_indx + 2) | SW_REGION3, 0, 1, CH_N);
            if(p10 == 0)
            {
                go_up_ok = 1;
                //go_down_ok=1;
            }
            else                                            // the song_number is editing, so the user can not move arrow up or down
            {
                go_up_ok = 0;
                go_down_ok = 0;
            }
            if((ProgCnt < PROG_NO_MAX) && !p10)
            {
                ProgCnt++;
                if(c_pos < PROG_NO_MAX) //the max c_pos is PROG_NO_MAX
                    c_pos++;
            }

        }
        else                                                // user input a number which is greater than the # of songs
        {
            //if(ProgCnt==0) 
            //c_pos = 1;

            PrintOsdMsg(STR_OS_SPACE, (t_indx + 2) | SW_REGION3, 0, 0, CH_N);
            PrintOsdMsg(STR_OS_HAND, (t_indx + 2) | SW_REGION3, 1, 0, CH_N);
            delay_flag = t_indx + 2;    // the location of showing "--",
            //the functionality of showing "--" is in polling_ir()

            go_up_ok = 1;                           // can go up
            go_down_ok = 0;                     // can not go down
            prog[c_pos - 1] = 0;
            ir_select_number = 0;
        }

        //psprintf(linebuf,"Cpos:%d ProgCnt:%d t_indx:%d\n",c_pos,ProgCnt,t_indx);
        //epp_write_wait(linebuf);
        //move to next page or next item
        if(t_indx == MAX_LINE && p10 == 0 && !(ProgCnt % t_indx))   //page change ready
            prog_page_action |= PAGE_CHG_RDY;
        else
        {
#ifdef MONE_PROG
            epp_write("item change ready \n");
#endif
            prog_page_action |= ARR_MOV_RDY;
        }
    }
    else                                                    //Edit only
    {
        if(prog[c_pos - 1] < temp)  //the max song_number is temp-1
        {
            if(p10 == 1)
              psprintf(RegionValStr[t_indx + 2], "%02d+", prog[c_pos - 1]);
            else
                psprintf(RegionValStr[t_indx + 2], "%02d", prog[c_pos - 1]);
            PrintOsdMsg(STR_OS_SPACE, (t_indx + 2) | SW_REGION3, 1, 0, CH_N);
            PrintOsdMsg(STR_OS_NULL, (t_indx + 2) | SW_REGION3, 0, 1, CH_N);

            if(p10 == 0)
            {
                if(t_indx == MAX_LINE)
                {
                    go_down_ok = 1;
                    go_up_ok = 1;
                    prog_func_down();
                    if(c_pos > ProgCnt)
                        go_down_ok = 0;
                }
                else
                {
                    PrintOsdMsg(STR_OS_SPACE, (t_indx + 2) | SW_REGION2, 0, 0, CH_N);
                    PrintOsdMsg(STR_OS_ARROW, (t_indx + 3) | SW_REGION2, 0, 0, CH_N);
                    c_pos++;
                    if(c_pos <= ProgCnt)
                    {
                        go_up_ok = 1;
                        go_down_ok = 1;
                    }
                }

            }
            else
            {
                go_up_ok = 0;
                go_down_ok = 0;
            }
        }
        else                                                //song_nimber is too large
        {
            PrintOsdMsg(STR_OS_SPACE, (t_indx + 2) | SW_REGION3, 0, 0, CH_N);
            PrintOsdMsg(STR_OS_HAND, (t_indx + 2) | SW_REGION3, 1, 0, CH_N);
            delay_flag = t_indx + 2;

            if(c_pos == PROG_NO_MAX)
                go_up_ok = 1;
            else
            {
                go_up_ok = 0;
                go_down_ok = 0;
            }
            prog[c_pos - 1] = 0;
            ir_select_number = 0;
        }
    }

    arrow_wait_time = 1;

#ifdef MONE_PROG
    {
        int     i;

        for(i = 0; i < 5; i++)
        {
            psprintf(linebuf, "%d %d \n", i, prog[i]);
            epp_write(linebuf);
        }
    }
#endif

}

void prog_next(void)
{
    if(ProgCnt)
    {
        ProgIndx = (ProgIndx >= ProgCnt) ? 1 : (ProgIndx + 1);
    }
}
void prog_prev(void)
{
    if(ProgCnt)
    {
        ProgIndx = ((ProgIndx > 1) ? ProgIndx - 1 : ProgCnt);
    }
}

/*
**
*/
void redraw_prog_page(void)
{
    BYTE    i;

#ifdef MONE_PROG
    psprintf(linebuf, "redraw c_pos:%x\n", c_pos);
    epp_write(linebuf);
#endif
#if 1
    for(i = 0; i < MAX_LINE; i++)   //across page,update new page
    {
        //title number
        psprintf(RegionValStr[i + 1 + 2], "%02d", c_pos + i);
        PrintOsdMsg(STR_OS_NULL, (i + 1 + 2) | SW_REGION1, 0, 1, CH_N);

        PrintOsdMsg(STR_OS_DDASH, (i + 1 + 2) | SW_REGION3, 0, 0, CH_N);
    }
    PrintOsdMsg(STR_OS_SPACE, (MAX_LINE + 2) | SW_REGION2, 0, 0, CH_N);
    PrintOsdMsg(STR_OS_ARROW, (1 + 2) | SW_REGION2, 0, 0, CH_N);
#endif

}

/*
**
*/
void ShowProgPage(void)
{
    BYTE    i;

    osd_init_prog();
    InitSW_region();
    //?t_disp = 0;
    c_pos = 1;

#ifdef IR_SCORE_ON                          //jhuang 2002/5/17
    if(score_status == SCORE_L || score_status == SCORE_R)
        PrintOsdMsg(STR_OS_SPACE, REGION2, 1, 0, CH_N);
#endif

    
    //for(i = 0; i < 3; i++)
    //  linebuf[i] = 0x20;
    
    //linebuf[3] = 0xb3;                        //Ρ
    //linebuf[4] = 0x20;
    //linebuf[5] = 0x20;
    //linebuf[6] = '\n';

    //strcpy(RegionValStr[REGION2], linebuf);

    if(osd_font_mode)
    psprintf(RegionValStr[REGION2],"   "OS_TRACK" ");
    else
    psprintf(RegionValStr[REGION2],"  TRK");

    
    PrintOsdMsg(STR_OS_PROG, REGION2 | SW_REGION1, 0, 1, CH_N);
    PrintOsdMsg(STR_OS_ARROW,REGION3 | SW_REGION2, 0, 0, CH_N);

    for(i = 1; i <= MAX_LINE; i++)
    {
        psprintf(RegionValStr[i + REGION2], "%02d", i);
        PrintOsdMsg(STR_OS_NULL, (i + REGION2) | SW_REGION1, 0, 1, CH_N);
        PrintOsdMsg(STR_OS_DDASH, (i + REGION2) | SW_REGION3, 0, 0, CH_N);
    }
}

⌨️ 快捷键说明

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