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

📄 ap_common.s01

📁 5807收音机模块用于炬力平台
💻 S01
字号:
	NAME	ap_common(17)
	RSEG	COM_RES(0)
	RSEG	UDATA0(0)
	RSEG	IDATA0(0)
	RSEG	CDATA0(0)
	EXTERN	PutSDImage
	PUBLIC	ResClose
	PUBLIC	ResOpen
	PUBLIC	ResShowPic
	EXTERN	SD_FClose
	EXTERN	SD_FOpen
	EXTERN	SD_FRead
	EXTERN	SD_FSeek
	EXTERN	UpdateScreen
	PUBLIC	res_entry
	PUBLIC	res_fp
	PUBLIC	res_head
	PUBLIC	res_region
	PUBLIC	ui_auto_select
	PUBLIC	ui_auto_update
	PUBLIC	ui_run_realtime
	EXTERN	?CLZ80B_4_04_L00
	EXTERN	?L_LSH_L03
	EXTERN	?BANK_FAST_LEAVE_L08
	RSEG	COM_RES
ResOpen:
; 1.	/*
; 2.	*******************************************************************************
; 3.	*                ACTOS AP
; 4.	*        ap common lib file, udisk use this file too
; 5.	*
; 6.	*        (c) Copyright, Actions Co,Ld.                             
; 7.	*             All Right Reserved                          
; 8.	*
; 9.	*******************************************************************************
; 10.	*/ 
; 11.	#pragma codeseg(COM_RES)
; 12.	
; 13.	#ifdef USB_DISK_USING
; 14.	
; 15.	/* usb disk 不使用调试宏*/
; 16.	#define NAPDEBUG
; 17.	
; 18.	/* usb disk 使用 non_bankl 方式call 这些函数*/
; 19.	#pragma function=non_banked
; 20.	
; 21.	#endif  /* USB_DISK_USING*/
; 22.	
; 23.	#include "ap_common.h"
; 24.	
; 25.	//========== global field ===============
; 26.	
; 27.	//操作这些资源时不能被中断, 这些变量应该放在所有ap可见的地方
; 28.	SD_FILE *res_fp;
; 29.	res_head_t res_head;
; 30.	res_entry_t res_entry;
; 31.	region_t res_region;
; 32.	
; 33.	//请不要把这个变量定义在非IDATA0 段,否则不能初始化
; 34.	BOOL ui_auto_update=TRUE;       //是否自动刷新屏幕
; 35.	BOOL ui_auto_select=TRUE;       //是否自动确认
; 36.	BOOL ui_run_realtime=FALSE;     //控件跑实时模式
; 37.	
; 38.	/*
; 39.	********************************************************************************
; 40.	* Description : 打开资源文件
; 41.	*
; 42.	* Arguments   : filename, 资源文件名字
; 43.	*
; 44.	* Returns     : 成功,文件指针
; 45.	                失败, NULL
; 46.	*
; 47.	* Notes       :
; 48.	*
; 49.	********************************************************************************
; 50.	*/
; 51.	SD_FILE *ResOpen(const char * filename)
; 52.	{    
	PUSH	BC
	PUSH	DE
; 53.	        //open res file
; 54.	        res_fp = SD_FOpen(filename, 0);
	LD	C,0
	CALL	LWRD SD_FOpen
	LD	(res_fp),HL
; 55.	        if(res_fp == NULL ) return NULL;
	LD	A,L
	OR	H
	JR	Z,?0015
?0002:
?0003:
; 56.	    
; 57.	        //check magic "RES 0x19"
; 58.	        SD_FRead(res_fp, &res_head, sizeof(res_head));
	LD	HL,16
	PUSH	HL
	LD	BC,res_head
	LD	DE,(res_fp)
	CALL	LWRD SD_FRead
	POP	AF
; 59.	        if( res_head.magic[0] != 'R' || 
; 60.	                res_head.magic[1] != 'E' ||
; 61.	                res_head.magic[2] != 'S' ||
; 62.	                res_head.magic[3] != 0x19 )
	LD	A,(res_head)
	CP	82
	JR	NZ,?0006
	LD	A,(res_head+1)
	CP	69
	JR	NZ,?0006
	LD	A,(res_head+2)
	CP	83
	JR	NZ,?0006
	LD	A,(res_head+3)
	CP	25
	JR	Z,?0005
?0006:
?0007:
?0004:
; 63.	        {
; 64.	                SD_FClose(res_fp);
	LD	DE,(res_fp)
	CALL	LWRD SD_FClose
; 65.	                return NULL;
?0015:
	LD	HL,0
; 66.	        }
	JR	?0008
?0005:
; 67.	
; 68.	        //check count
; 69.	        ASSERT(res_head.counts == UIID_MAX);
; 70.	
; 71.	        //return ok
; 72.	        return res_fp;    
	LD	HL,(res_fp)
; 73.	}
?0008:
	POP	AF
	POP	BC
	JP	LWRD ?BANK_FAST_LEAVE_L08
ResClose:
; 74.	
; 75.	/*
; 76.	********************************************************************************
; 77.	* Description : 关闭资源文件
; 78.	*
; 79.	* Arguments   :
; 80.	*
; 81.	* Returns     :
; 82.	*
; 83.	* Notes       :
; 84.	*
; 85.	********************************************************************************
; 86.	*/
; 87.	void ResClose(const SD_FILE *fp)
; 88.	{
	PUSH	DE
; 89.	        SD_FClose(fp);
	CALL	LWRD SD_FClose
; 90.	}
	POP	HL
	JP	LWRD ?BANK_FAST_LEAVE_L08
ResShowPic:
; 91.	
; 92.	/*
; 93.	********************************************************************************
; 94.	* Description : 显示128*32 的图形
; 95.	*
; 96.	* Arguments   : id, 资源代号
; 97.	*
; 98.	* Returns     : 成功,1  失败,0
; 99.	*
; 100.	* Notes       :
; 101.	*
; 102.	********************************************************************************
; 103.	*/
; 104.	//int ResShowLogo(WORD id)
; 105.	//{
; 106.	//      ASSERT(id <= UIID_MAX);
; 107.	//      
; 108.	//      //读entry
; 109.	//      SD_FSeek(res_fp, SEEK_SET,  (long)id * sizeof(res_entry_t));
; 110.	//      SD_FRead(res_fp, &res_entry, sizeof(res_entry_t));
; 111.	//      if(res_entry.type != RES_TYPE_LOGO) return 0;
; 112.	//      ASSERT(res_entry.length <= 512);
; 113.	//
; 114.	//      //读数据
; 115.	//      SD_FSeek(res_fp, SEEK_SET, res_entry.offset);
; 116.	//      res_region.width = SCR_WIDTH;
; 117.	//      res_region.height = SCR_HEIGHT;
; 118.	//
; 119.	//      //显示logo
; 120.	//      res_region.x = 0;
; 121.	//      res_region.y = 0;
; 122.	//      PutSDImage(&res_region, res_fp->rwpointer);
; 123.	//      if(ui_auto_update) UpdateScreen(&res_region);
; 124.	//      return 1;       
; 125.	//}
; 126.	
; 127.	/*
; 128.	********************************************************************************
; 129.	* Description : 在指定位置显示图形
; 130.	*
; 131.	* Arguments   : id, 资源代号
; 132.	                x,y, 屏幕坐标
; 133.	*
; 134.	* Returns     : 成功, 1
; 135.	                失败, 0
; 136.	*
; 137.	* Notes       :
; 138.	*
; 139.	********************************************************************************
; 140.	*/
; 141.	int ResShowPic(WORD id, uchar x, uchar y)
; 142.	{
	PUSH	BC
	PUSH	DE
	PUSH	AF
	PUSH	AF
; 143.	        WORD buf[2];    //buffer for sd read
; 144.	
; 145.	        ASSERT(id <= UIID_MAX);
; 146.	        
; 147.	        //读entry
; 148.	        SD_FSeek(res_fp, SEEK_SET, (long)id * sizeof(res_entry_t));
	LD	L,E
	LD	H,D
	LD	BC,0
	LD	A,4
	CALL	LWRD ?L_LSH_L03
	PUSH	BC
	PUSH	HL
	LD	C,0
	LD	DE,(res_fp)
	CALL	LWRD SD_FSeek
	POP	HL
	POP	HL
; 149.	        SD_FRead(res_fp, &res_entry, sizeof(res_entry_t));
	LD	HL,16
	PUSH	HL
	LD	BC,res_entry
	LD	DE,(res_fp)
	CALL	LWRD SD_FRead
	POP	AF
; 150.	        if(res_entry.type != RES_TYPE_PIC) return 0;
	LD	A,(res_entry+6)
	DEC	A
	JR	Z,?0010
?0009:
	LD	HL,0
; 151.	        ASSERT(res_entry.length <= 512);
	JR	?0013
?0010:
; 152.	
; 153.	        //读数据
; 154.	        SD_FSeek(res_fp, SEEK_SET, res_entry.offset);
	LD	HL,(res_entry+2)
	PUSH	HL
	LD	HL,(res_entry)
	PUSH	HL
	LD	C,A
	LD	DE,(res_fp)
	CALL	LWRD SD_FSeek
	POP	HL
	POP	HL
; 155.	        //SD_FRead(res_fp, &(res_region.width), 2);
; 156.	        //SD_FRead(res_fp, &(res_region.height), 2);
; 157.	        SD_FRead(res_fp, buf, sizeof(buf));
	LD	HL,4
	PUSH	HL
	DEC	HL
	DEC	HL
	ADD	HL,SP
	LD	C,L
	LD	B,H
	LD	DE,(res_fp)
	CALL	LWRD SD_FRead
	POP	AF
; 158.	        //ASSERT(buf[0] <= 128);
; 159.	        //ASSERT(buf[1] <= 32); 
; 160.	        res_region.width = (char)buf[0];
	LD	HL,0
	ADD	HL,SP
	LD	A,(HL)
	LD	(res_region+2),A
; 161.	        res_region.height = (char)buf[1];
	INC	HL
	INC	HL
	LD	A,(HL)
	LD	(res_region+3),A
; 162.	        
; 163.	        //显示
; 164.	        res_region.x = x;
	LD	HL,6
	ADD	HL,SP
	LD	A,(HL)
	LD	(res_region),A
; 165.	        res_region.y = y;
	LD	HL,12
	ADD	HL,SP
	LD	A,(HL)
	LD	(res_region+1),A
; 166.	        PutSDImage(&res_region, res_fp->rwpointer);
	LD	HL,20
	LD	BC,(res_fp)
	ADD	HL,BC
	LD	C,(HL)
	INC	HL
	LD	B,(HL)
	INC	HL
	LD	E,(HL)
	INC	HL
	LD	D,(HL)
	PUSH	DE
	PUSH	BC
	LD	DE,res_region
	CALL	LWRD PutSDImage
	POP	HL
	POP	HL
; 167.	        if(ui_auto_update) UpdateScreen(&res_region);
	LD	A,(ui_auto_update)
	OR	A
	JR	Z,?0012
?0011:
	LD	DE,res_region
	CALL	LWRD UpdateScreen
?0012:
; 168.	        return 1;
	LD	HL,1
; 169.	}
?0013:
	POP	AF
	POP	AF
	POP	AF
	POP	AF
	JP	LWRD ?BANK_FAST_LEAVE_L08
; 170.	
; 171.	/*
; 172.	bool SDCardPullOutSign(char CurDisk)
; 173.	{
; 174.	//送出已拔出标志
; 175.	    if (CurDisk == 'H')
; 176.	    {
; 177.	        if (DRV_DetectUD(1) != 0x20)
; 178.	        { 
; 179.	            return TRUE; //卡已不在,送出拔出标志
; 180.	        }
; 181.	    }
; 182.	    return FALSE;
; 183.	}
; 184.	
; 185.	*/
; 186.	#pragma function=default
; 187.	
	RSEG	UDATA0
res_fp:
	DEFS	2
res_head:
	DEFS	16
res_entry:
	DEFS	16
res_region:
	DEFS	4
	RSEG	IDATA0
ui_auto_update:
	DEFS	1
ui_auto_select:
	DEFS	1
ui_run_realtime:
	DEFS	1
	RSEG	CDATA0
	DEFB	1
	DEFB	1
	DEFB	0
	END

⌨️ 快捷键说明

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