ui_playlist.c
来自「MP3 整个 SDK」· C语言 代码 · 共 236 行
C
236 行
/*
*******************************************************************************
* ACTOS AP
* ap common lib, directory control file
*
* (c) Copyright, Actions Co,Ld.
* All Right Reserved
*
* $Id: ui_playlist.c,v 1.1.1.1 2006/05/22 03:23:59 selina Exp $
*******************************************************************************
*/
#pragma codeseg(COM_PLAYLIST)
#include "ap_common.h"
#include "list.h"
#include "filesys.h"
WORD playlist_active,cur_grouplist; //目录总数,文件总数和浏览项数,浏览活动项
extern WORD PlaylistClassTotal;
extern WORD PlaylistCurClass;
extern BYTE ScrollFlag;
#pragma memory=dataseg(RCODE)
#pragma memory=default
void ShowPlaylist(BYTE top,BYTE bottom,BYTE Old_active,BYTE active,char *Longnamebuf,BYTE string_id,BYTE ScrollMode);
void reinit_idm_buf_playlist(int top, int bottom, char *Longnamebuf, BYTE string_id,BOOL direction);
static void DmaCpy(WORD descadd, BYTE descpg, WORD srcadd, BYTE srcpg, WORD Length);
/********************************************************************************
* Description : select the directory.
*
* Arguments :
* location: get thedisk type
* type : show file kind
* string_id: language type
* Returns :
* other: Successful
* 0: Fail, detail information in fselError
* Notes : only select the valid directory
*
********************************************************************************/
int ui_playlist(file_location_t *location, BYTE type,BYTE string_id)
{
BYTE i, pagebak,TimeoutCnt;
char * Strname;
BYTE result;
char key;
int top, bottom;
if ( !fselSetLocation(location) )
{
return RESULT_IGNORE;
}
if (PlaylistClassTotal == 0)
return RESULT_IGNORE;
////////////////////////////////换页//////////////////////////////////////
DmaCpy( 0x4000, 0x06, 0x4000, 0x07, 0x2000-1 ); //备份第7页0x4000~0x6000的8K代码到第6页0x4000~0x6000
i = input8(0x05);
output8(0x05, 0xf6);
pagebak = SetSWAPAddress(0x06);
Strname = (char *)STRNAMEBUF;
////////////////////////////////换页//////////////////////////////////////
memset(Strname, 0x00, LISTNAME_DISP_LENNGTH+1);
while(PlaylistCurClass>1) //返回根目录
{
fselGetPrevGroup(Strname);
}
top=0;
bottom=4;
playlist_active=0;
cur_grouplist=0;
if(PlaylistClassTotal<5)
bottom=PlaylistClassTotal-1;
FSELGetLocation(location); //保存location
reinit_idm_buf_playlist(top, bottom, Strname, string_id,TRUE);
FSELSetLocation(location);
ShowPlaylist(top,bottom,playlist_active,playlist_active,Strname,string_id,1);
while(ap_get_message()!=0) {;} //丢掉多余按键
ap_message_init(NULL);
while(1)
{
//handle msg
key = ap_get_message();
switch(key)
{
case AP_KEY_NEXT:
case AP_KEY_NEXT | AP_KEY_HOLD:
if(playlist_active<PlaylistClassTotal -1 ) //当前项小于总列表数
{
fselGetNextGroup(Strname);
playlist_active++;
if(playlist_active/5==cur_grouplist)
{
ShowPlaylist(top,bottom,playlist_active-1,playlist_active,Strname,string_id,1);
}
else
{
cur_grouplist=cur_grouplist+1;
top=(playlist_active/5)*5; //顶的序号
bottom=top+4; //底的序号
if(bottom>(PlaylistClassTotal-1))
bottom=PlaylistClassTotal-1;
FSELGetLocation(location);
reinit_idm_buf_playlist(top, bottom, Strname, string_id,TRUE); //换页要重新初始化IDM数据
FSELSetLocation(location);
ShowPlaylist(top,bottom,playlist_active,playlist_active,Strname,string_id,1);
}
}
while(ap_get_message() != 0);
break;
case AP_KEY_PREV:
case AP_KEY_PREV | AP_KEY_HOLD :
if(playlist_active >0)
{
fselGetPrevGroup(Strname);
playlist_active--;
if(playlist_active/5==cur_grouplist)
{
ShowPlaylist(top,bottom,playlist_active+1,playlist_active,Strname,string_id,1);
}
else
{
cur_grouplist=cur_grouplist-1;
top=(playlist_active/5)*5; //顶的序号
bottom=top+4; //底的序号
FSELGetLocation(location);
reinit_idm_buf_playlist(top, bottom, Strname, string_id,FALSE); //换页要重新初始化IDM数据
FSELSetLocation(location);
ShowPlaylist(top,bottom,playlist_active,playlist_active,Strname,string_id,1);
}
}
while(ap_get_message() != 0);
break;
case AP_KEY_PLAY | AP_KEY_UP:
FSELSetLocation(location); //restore the selecting result
result = RESULT_IGNORE;
goto funreturn;
break;
case AP_KEY_MODE | AP_KEY_LONG:
if ( FSELGetLocation(location) ) //store the selecting result
result = RESULT_NULL;
else
result = RESULT_IGNORE;
goto funreturn;
break;
case AP_KEY_MODE | AP_KEY_UP:
break;
case AP_MSG_WAIT_TIMEOUT:
TimeoutCnt++;
if ( TimeoutCnt >= 24 ) //192秒后退出,因为要看长名滚屏
{
if (FSELGetLocation(location)) //store the selecting result
result = RESULT_NULL;
else
result = RESULT_IGNORE;
goto funreturn;
}
break;
case AP_MSG_SD_OUT:
//如在游览SD卡,但SD卡又被拔出,就返回拔出信号
if (location->disk == 'H')
{
result = RESULT_SD_OUT;
goto funreturn;
}
break;
case AP_MSG_SD_IN:
break;
case AP_MSG_RTC:
break;
default:
key=ap_handle_hotkey(key);
if(key == RESULT_REDRAW)
{
ShowPlaylist(top,bottom,playlist_active,playlist_active,Strname,string_id,1);
}
else if( key != 0 )
{
FSELGetLocation(location); //store the selecting result
result = key;
goto funreturn;
}
if(ScrollFlag)
ShowPlaylist(top,bottom,playlist_active,playlist_active,Strname,string_id,0);
} //switch()
}
funreturn:
////////////////////////////////换页//////////////////////////////////////
DmaCpy( 0x4000, 0x07, 0x4000, 0x06, 0x2000-1 ); //恢复8K代码到第7页
output8(0x05, i);
SetSWAPAddress(pagebak);
////////////////////////////////换页//////////////////////////////////////
return result;
}
static void DmaCpy(WORD descadd, BYTE descpg, WORD srcadd, BYTE srcpg, WORD Length)
{
output8(REG14_DMA2SRCAddr0, (BYTE)(srcadd));
output8(REG15_DMA2SRCAddr1, (BYTE)(srcadd >> 8));
output8(REG16_DMA2SRCAddr2, 0x00);
output8(REG17_DMA2SRCAddr3, 0x40); //IDM/IPM/ZRAM2
output8(REG18_DMA2SRCAddrIntSramReg, srcpg); //ZRAM2PAGE
output8(REG19_DMA2DSTAddr0, (BYTE)(descadd));
output8(REG1A_DMA2DSTAddr1, (BYTE)(descadd >> 8));
output8(REG1B_DMA2DSTAddr2, 0x00);
output8(REG1C_DMA2DSTAddr3, 0x40); //IDM/IPM/ZRAM2
output8(REG1D_DMA2DSTAddrIntSram, descpg); //IDMHPAGE_06
output8(REG1E_DMA2ByteCounterLow, (BYTE)(Length));
output8(REG1F_DMA2ByteCounterHi, (BYTE)(Length >> 8));
output8(REG20_DMA2Mode, 0x00);
output8(REG21_DMA2CMD, 0x01);
while( input8(REG21_DMA2CMD)&0x01 != 0x00 ) {}
return;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?