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

📄 ap_common.s01

📁 MP3 整个 SDK
💻 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	ui_auto_select
	PUBLIC	ui_auto_update
	PUBLIC	ui_run_realtime
	EXTERN	?CLZ80B_4_04_L00
	EXTERN	?L_LSH_L03
	EXTERN	?BANK_LEAVE_DIRECT_L08
	EXTERN	?BANK_FAST_LEAVE_L08
	EXTERN	?ENT_PARM_DIRECT_L09
	EXTERN	?ENT_AUTO_DIRECT_L09
	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.	//请不要把这个变量定义在非IDATA0 段,否则不能初始化
; 38.	BOOL ui_auto_update=TRUE;    //是否自动刷新屏幕
; 39.	BOOL ui_auto_select=TRUE;    //是否自动确认
; 40.	BOOL ui_run_realtime=FALSE;    //控件跑实时模式
; 41.	
; 42.	/*
; 43.	********************************************************************************
; 44.	* Description : 打开资源文件
; 45.	*
; 46.	* Arguments   : filename, 资源文件名字
; 47.	*
; 48.	* Returns     : 成功,文件指针
; 49.	        失败, NULL
; 50.	*
; 51.	* Notes       :
; 52.	*
; 53.	********************************************************************************
; 54.	*/
; 55.	SD_FILE *ResOpen(const char * filename)
; 56.	{    
	CALL	LWRD ?ENT_PARM_DIRECT_L09
; 57.	        //open res file
; 58.	        res_fp = SD_FOpen(filename, 0);
	LD	C,0
	CALL	LWRD SD_FOpen
	LD	(res_fp),HL
; 59.	        if(res_fp == NULL ) return NULL;
	LD	A,L
	OR	H
	JR	Z,?0019
?0002:
?0003:
; 60.	    
; 61.	    //check magic "RES 0x19"
; 62.	    SD_FRead(res_fp, &res_head, sizeof(res_head));
	LD	HL,16
	PUSH	HL
	LD	BC,res_head
	CALL	LWRD ?0021
	POP	AF
; 63.	    if( res_head.magic[0] != 'R' || 
; 64.	        res_head.magic[1] != 'E' ||
; 65.	        res_head.magic[2] != 'S' ||
; 66.	        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:
; 67.	    {
; 68.	        SD_FClose(res_fp);
	LD	DE,(res_fp)
	CALL	LWRD SD_FClose
; 69.	        return NULL;
?0019:
	LD	HL,0
; 70.	    }
	JR	?0008
?0005:
; 71.	
; 72.	    //check count
; 73.	    ASSERT(res_head.counts == UIID_MAX);
; 74.	
; 75.	    //return ok
; 76.	    return res_fp;    
	LD	HL,(res_fp)
; 77.	}
?0008:
	JP	LWRD ?BANK_LEAVE_DIRECT_L08
?0022:
	LD	BC,res_entry
?0021:
	LD	DE,(res_fp)
	JP	LWRD SD_FRead
ResClose:
; 78.	
; 79.	/*
; 80.	********************************************************************************
; 81.	* Description : 关闭资源文件
; 82.	*
; 83.	* Arguments   :
; 84.	*
; 85.	* Returns     :
; 86.	*
; 87.	* Notes       :
; 88.	*
; 89.	********************************************************************************
; 90.	*/
; 91.	void ResClose(const SD_FILE *fp)
; 92.	{
	PUSH	DE
; 93.	    SD_FClose(fp);
	CALL	LWRD SD_FClose
; 94.	}
	POP	HL
	JP	LWRD ?BANK_FAST_LEAVE_L08
ResShowPic:
; 95.	
; 96.	/*
; 97.	********************************************************************************
; 98.	* Description : 在指定位置显示图形
; 99.	*
; 100.	* Arguments   : id, 资源代号
; 101.	        x,y, 屏幕坐标
; 102.	*
; 103.	* Returns     : 成功, 1
; 104.	        失败, 0
; 105.	*
; 106.	* Notes       :
; 107.	*
; 108.	********************************************************************************
; 109.	*/
; 110.	int ResShowPic(WORD id, uchar x, uchar y)
; 111.	{
	CALL	LWRD ?ENT_AUTO_DIRECT_L09
	DEFW	65532
; 112.	    WORD buf[2];    //buffer for sd read
; 113.	
; 114.	    ASSERT(id <= UIID_MAX);
; 115.	    
; 116.	    //读entry
; 117.	    SD_FSeek(res_fp, SEEK_SET, (long)id * sizeof(res_entry_t));
	CALL	LWRD ?0023
	PUSH	BC
	PUSH	HL
	CALL	LWRD ?0024
	POP	HL
	POP	HL
; 118.	    SD_FRead(res_fp, &res_entry, sizeof(res_entry_t));
	LD	HL,16
	PUSH	HL
	CALL	LWRD ?0022
	POP	AF
; 119.	    if(res_entry.type != RES_TYPE_PIC) return 0;
	LD	A,(res_entry+6)
	DEC	A
	JR	Z,?0010
?0009:
	LD	HL,0
; 120.	    ASSERT(res_entry.length <= 512);
	JR	?0013
?0010:
; 121.	
; 122.	    //读数据
; 123.	    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
	CALL	LWRD ?0025
	POP	HL
	POP	HL
; 124.	 
; 125.	    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
; 126.	 
; 127.	    res_region.width = (char)buf[0];
	LD	A,(IX-4)
	LD	(res_region+2),A
; 128.	    res_region.height = (char)buf[1];
	LD	A,(IX-2)
	LD	(res_region+3),A
; 129.	    
; 130.	    //显示
; 131.	    res_region.x = x;
	LD	A,(IX+4)
	LD	(res_region),A
; 132.	    res_region.y = y;
	LD	A,(IX+10)
	LD	(res_region+1),A
; 133.	    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
; 134.	    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:
; 135.	    return 1;
	LD	HL,1
; 136.	}
?0013:
	JP	LWRD ?BANK_LEAVE_DIRECT_L08
?0023:
	LD	L,(IX+2)
	LD	H,(IX+3)
	LD	BC,0
	LD	A,4
	JP	LWRD ?L_LSH_L03
?0024:
	LD	C,0
?0025:
	LD	DE,(res_fp)
	JP	LWRD SD_FSeek
ResInvertShowPic:
; 137.	#ifdef InvertFlag 
; 138.	int ResInvertShowPic(WORD id, uchar x, uchar y)
; 139.	{
	CALL	LWRD ?ENT_AUTO_DIRECT_L09
	DEFW	65532
; 140.	    WORD buf[2];    //buffer for sd read
; 141.	
; 142.	    ASSERT(id <= UIID_MAX);
; 143.	    
; 144.	    //读entry
; 145.	    SD_FSeek(res_fp, SEEK_SET, (long)id * sizeof(res_entry_t));
	CALL	LWRD ?0023
	PUSH	BC
	PUSH	HL
	CALL	LWRD ?0024
	POP	HL
	POP	HL
; 146.	    SD_FRead(res_fp, &res_entry, sizeof(res_entry_t));
	LD	HL,16
	PUSH	HL
	CALL	LWRD ?0022
	POP	AF
; 147.	    if(res_entry.type != RES_TYPE_PIC) return 0;
	LD	A,(res_entry+6)
	DEC	A
	JR	Z,?0015
?0014:
	LD	HL,0
; 148.	    ASSERT(res_entry.length <= 512);
	JR	?0018
?0015:
; 149.	
; 150.	    //读数据
; 151.	    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
	CALL	LWRD ?0025
	POP	HL
	POP	HL
; 152.	 
; 153.	    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
; 154.	 
; 155.	    res_region.width = (char)buf[0];
	LD	A,(IX-4)
	LD	(res_region+2),A
; 156.	    res_region.height = (char)buf[1];
	LD	A,(IX-2)
	LD	(res_region+3),A
; 157.	    
; 158.	    //显示
; 159.	    res_region.x = x;
	LD	A,(IX+4)
	LD	(res_region),A
; 160.	    res_region.y = y;
	LD	A,(IX+10)
	LD	(res_region+1),A
; 161.	    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
; 162.	    InvertRegion(&res_region);
	LD	DE,res_region
	CALL	LWRD InvertRegion
; 163.	    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:
; 164.	    return 1;
	LD	HL,1
; 165.	} 
?0018:
	JP	LWRD ?BANK_LEAVE_DIRECT_L08
; 166.	#endif 
; 167.	
; 168.	#pragma function=default
; 169.	
	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 + -