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

📄 ap_common.s01

📁 炬力方案176*132软件源码,适用于AK1025
💻 S01
字号:
	NAME	ap_common(17)
	RSEG	COM_RES(0)
	RSEG	UDATA0(0)
	RSEG	IDATA0(0)
	RSEG	CDATA0(0)
	EXTERN	InvertRegion
	EXTERN	PutSDImage
	PUBLIC	ResClose
	PUBLIC	ResInvertShowPic
	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	scroll_cnt
	PUBLIC	str_pt
	PUBLIC	strhead_pt
	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.	*  $Id: ap_common.c,v 1.1.1.1 2006/05/22 03:23:59 selina Exp $
; 10.	*******************************************************************************
; 11.	*/ 
; 12.	#pragma codeseg(COM_RES)
; 13.	
; 14.	#ifdef USB_DISK_USING
; 15.	
; 16.	/* usb disk 不使用调试宏*/
; 17.	#define NAPDEBUG
; 18.	
; 19.	/* usb disk 使用 non_bankl 方式call 这些函数*/
; 20.	#pragma function=non_banked
; 21.	
; 22.	#endif    /* USB_DISK_USING*/
; 23.	
; 24.	#include "ap_common.h"
; 25.	#ifndef USB_DISK_USING
; 26.	#define InvertFlag
; 27.	#endif
; 28.	//========== global field ===============
; 29.	
; 30.	//操作这些资源时不能被中断, 这些变量应该放在所有ap可见的地方
; 31.	SD_FILE *res_fp;
; 32.	res_head_t res_head;
; 33.	res_entry_t res_entry;
; 34.	region_t res_region;
; 35.	
; 36.	//滚屏相关参数 
; 37.	char *str_pt;//字符串当前指针
; 38.	char *strhead_pt;//字串首址记录
; 39.	BYTE scroll_cnt;  
; 40.	 
; 41.	//请不要把这个变量定义在非IDATA0 段,否则不能初始化
; 42.	BOOL ui_auto_update=TRUE;    //是否自动刷新屏幕
; 43.	BOOL ui_auto_select=TRUE;    //是否自动确认
; 44.	BOOL ui_run_realtime=FALSE;    //控件跑实时模式
; 45.	
; 46.	/*
; 47.	********************************************************************************
; 48.	* Description : 打开资源文件
; 49.	*
; 50.	* Arguments   : filename, 资源文件名字
; 51.	*
; 52.	* Returns     : 成功,文件指针
; 53.	        失败, NULL
; 54.	*
; 55.	* Notes       :
; 56.	*
; 57.	********************************************************************************
; 58.	*/
; 59.	SD_FILE *ResOpen(const char * filename)
; 60.	{    
	PUSH	BC
	PUSH	DE
; 61.	        //open res file
; 62.	        res_fp = SD_FOpen(filename, 0);
	LD	C,0
	CALL	LWRD SD_FOpen
	LD	(res_fp),HL
; 63.	        if(res_fp == NULL ) return NULL;
	LD	A,L
	OR	H
	JR	Z,?0020
?0002:
?0003:
; 64.	    
; 65.	    //check magic "RES 0x19"
; 66.	    SD_FRead(res_fp, &res_head, sizeof(res_head));
	LD	HL,16
	PUSH	HL
	LD	BC,res_head
	CALL	LWRD ?0021
	POP	AF
; 67.	    if( res_head.magic[0] != 'R' || 
; 68.	        res_head.magic[1] != 'E' ||
; 69.	        res_head.magic[2] != 'S' ||
; 70.	        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:
; 71.	    {
; 72.	        SD_FClose(res_fp);
	LD	DE,(res_fp)
	CALL	LWRD SD_FClose
; 73.	        return NULL;
?0020:
	LD	HL,0
; 74.	    }
	JR	?0008
?0005:
; 75.	
; 76.	    //check count
; 77.	    ASSERT(res_head.counts == UIID_MAX);
; 78.	
; 79.	    //return ok
; 80.	    return res_fp;    
	LD	HL,(res_fp)
; 81.	}
?0008:
	POP	AF
	POP	BC
	JP	LWRD ?BANK_FAST_LEAVE_L08
?0022:
	LD	BC,res_entry
?0021:
	LD	DE,(res_fp)
	JP	LWRD SD_FRead
ResClose:
; 82.	
; 83.	/*
; 84.	********************************************************************************
; 85.	* Description : 关闭资源文件
; 86.	*
; 87.	* Arguments   :
; 88.	*
; 89.	* Returns     :
; 90.	*
; 91.	* Notes       :
; 92.	*
; 93.	********************************************************************************
; 94.	*/
; 95.	void ResClose(const SD_FILE *fp)
; 96.	{
	PUSH	DE
; 97.	    SD_FClose(fp);
	CALL	LWRD SD_FClose
; 98.	}
	POP	HL
	JP	LWRD ?BANK_FAST_LEAVE_L08
ResShowPic:
; 99.	
; 100.	/*
; 101.	********************************************************************************
; 102.	* Description : 在指定位置显示图形
; 103.	*
; 104.	* Arguments   : id, 资源代号
; 105.	        x,y, 屏幕坐标
; 106.	*
; 107.	* Returns     : 成功, 1
; 108.	        失败, 0
; 109.	*
; 110.	* Notes       :
; 111.	*
; 112.	********************************************************************************
; 113.	*/
; 114.	int ResShowPic(WORD id, uchar x, uchar y)
; 115.	{
	PUSH	BC
	PUSH	DE
	PUSH	AF
	PUSH	AF
; 116.	    WORD buf[2];    //buffer for sd read
; 117.	
; 118.	    ASSERT(id <= UIID_MAX);
; 119.	    
; 120.	    //读entry
; 121.	    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
; 122.	    SD_FRead(res_fp, &res_entry, sizeof(res_entry_t));
	LD	HL,16
	PUSH	HL
	CALL	LWRD ?0022
	POP	AF
; 123.	    if(res_entry.type != RES_TYPE_PIC) return 0;
	LD	A,(res_entry+6)
	DEC	A
	JR	Z,?0010
?0009:
	LD	HL,0
; 124.	    ASSERT(res_entry.length <= 512);
	JR	?0013
?0010:
; 125.	
; 126.	    //读数据
; 127.	    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
; 128.	 
; 129.	    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
	CALL	LWRD ?0021
	POP	AF
; 130.	 
; 131.	    res_region.width = (char)buf[0];
	LD	HL,0
	ADD	HL,SP
	LD	A,(HL)
	LD	(res_region+2),A
; 132.	    res_region.height = (char)buf[1];
	INC	HL
	INC	HL
	LD	A,(HL)
	LD	(res_region+3),A
; 133.	    
; 134.	    //显示
; 135.	    res_region.x = x;
	LD	HL,6
	ADD	HL,SP
	LD	A,(HL)
	LD	(res_region),A
; 136.	    res_region.y = y;
	LD	HL,12
	ADD	HL,SP
	LD	A,(HL)
	LD	(res_region+1),A
; 137.	    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
; 138.	    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:
; 139.	    return 1;
	LD	HL,1
; 140.	}
?0013:
	POP	AF
	POP	AF
	POP	AF
	POP	AF
	JP	LWRD ?BANK_FAST_LEAVE_L08
ResInvertShowPic:
; 141.	#ifdef InvertFlag 
; 142.	int ResInvertShowPic(WORD id, uchar x, uchar y)
; 143.	{
	PUSH	BC
	PUSH	DE
	PUSH	AF
	PUSH	AF
; 144.	    WORD buf[2];    //buffer for sd read
; 145.	
; 146.	    ASSERT(id <= UIID_MAX);
; 147.	    
; 148.	    //读entry
; 149.	    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
; 150.	    SD_FRead(res_fp, &res_entry, sizeof(res_entry_t));
	LD	HL,16
	PUSH	HL
	CALL	LWRD ?0022
	POP	AF
; 151.	    if(res_entry.type != RES_TYPE_PIC) return 0;
	LD	A,(res_entry+6)
	DEC	A
	JR	Z,?0015
?0014:
	LD	HL,0
; 152.	    ASSERT(res_entry.length <= 512);
	JR	?0018
?0015:
; 153.	
; 154.	    //读数据
; 155.	    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
; 156.	 
; 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
	CALL	LWRD ?0021
	POP	AF
; 158.	 
; 159.	    res_region.width = (char)buf[0];
	LD	HL,0
	ADD	HL,SP
	LD	A,(HL)
	LD	(res_region+2),A
; 160.	    res_region.height = (char)buf[1];
	INC	HL
	INC	HL
	LD	A,(HL)
	LD	(res_region+3),A
; 161.	    
; 162.	    //显示
; 163.	    res_region.x = x;
	LD	HL,6
	ADD	HL,SP
	LD	A,(HL)
	LD	(res_region),A
; 164.	    res_region.y = y;
	LD	HL,12
	ADD	HL,SP
	LD	A,(HL)
	LD	(res_region+1),A
; 165.	    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
; 166.	    InvertRegion(&res_region);
	LD	DE,res_region
	CALL	LWRD InvertRegion
; 167.	    if(ui_auto_update) UpdateScreen(&res_region);
	LD	A,(ui_auto_update)
	OR	A
	JR	Z,?0017
?0016:
	LD	DE,res_region
	CALL	LWRD UpdateScreen
?0017:
; 168.	    return 1;
	LD	HL,1
; 169.	} 
?0018:
	POP	AF
	POP	AF
	POP	AF
	POP	AF
	JP	LWRD ?BANK_FAST_LEAVE_L08
; 170.	#endif  
; 171.	#pragma function=default
; 172.	    
; 173.	    
	RSEG	UDATA0
res_fp:
	DEFS	2
res_head:
	DEFS	16
res_entry:
	DEFS	16
res_region:
	DEFS	4
str_pt:
	DEFS	2
strhead_pt:
	DEFS	2
scroll_cnt:
	DEFS	1
	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 + -