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

📄 midiplay.lst

📁 midi file with midi play.it can run in the computer
💻 LST
📖 第 1 页 / 共 5 页
字号:
                     <      	.const	B_P_Check	= 0x0004;
                     <      	.const	B_SCLK1		= 0x0002;
                     <      	.const	B_SCLK0		= 0x0001;
                     <      	
                     <      	.const	P_UARTCmd2	= 0x704A;
                     <      	//read mode
                     <      	.const	B_RxRdy		= 0x0080;
                     <      	.const	B_TxRdy		= 0x0040;
                     <      	.const	B_FE		= 0x0020;
                     <      	.const	B_OE		= 0x0010;
                     <      	.const	B_PE		= 0x0008;
                     <      	.const	B_AcRdy		= 0x0001;
                     <      	
                     <      	//write mode
                     <      	.const	B_RxPinEn	= 0x0080;
                     <      	.const	B_TxPinEn	= 0x0040;
                     <      		
                     <      	.const	P_UARTData	= 0x704B;
                     <      	.const	P_UARTBR_Low	= 0x704C;
                     <      	.const	P_UARTBR_High	= 0x704D;
                     <      	.const	P_UARTABR_Low	= 0x704E;
                     <      	.const	P_UARTABR_High	= 0x704F;
                     <      	
                     <      	
                     <      	.const	P_SEL_IR_UART_CLK  = 0x7057;
                     <      	.const	B_SEL_IR_UART_CLK  = 0x0080;
                     <      	
                     <      	
                            	//.include		..\Function\Display.ASM
                            	.include		Keyscan.ASM
                     <      	//-----------------------------------------------------------------------
                     <      	//Program Name:		KeyScan.ASM
                     <      	//Applied Body:		SPT6604Aretf
                     <      	//Project Description:	This is a simple demo code for key scan.
                     <      	//Compile:		Sunplus u'nSP IDE
                     <      	//Programmer:		WangXu
                     <      	//Current Version:	V1.0
                     <      	//Written Date:		2002/10/30
                     <      	//-----------------------------------------------------------------------
                     <      	//-----------------------------------------------------------------------
000000C2             <      	.RAM
000000C2 00 00       <      	KeyScanFlag:		.DW	0 //b0~b7 - read portA buffer
                     <      					//b8~11 - state machine
                     <      					//b12~15 - current scan line
                     <      	
000000C3 00 00 00 00 <      	KeyStatusBuf:		.DW	0,0,0,0,0
         00 00 00 00
         00 00      
                     <      					//5 words - for key status
                     <      					//the high byte represents corresponding key is changed from 'released' to 'pressed'
                     <      					//the low byte represents corresponding key is pressed
                     <      	
000000C8 00 00       <      	KeyQueueBufPtr:		.DW	0 //b0~3 - read pointer
                     <      					//b4~7 - writer pointer
                     <      					//b8~11 - key queue size in use
                     <      					//b12~15- Key Bounce Timer
                     <      	.const	KeyDebounceTime	=	3*8192;		//( 3/512Hz = 6ms)
                     <      	
000000C9 00 00 00 00 <      	KeyQueueBuf:		.DW	0,0,0,0
         00 00 00 00
                     <      	//-----------------------------------------------------------------------
00008E25             <      	.code
                     <      	F_KeyTimerService:
00008E25 11 93 C8 00 <      		r1 =	[KeyQueueBufPtr]  
00008E27 09 C3 00 E0 <      		test	r1,0xE000
00008E29 04 5E       <      		jz	?L_KeyTimeOver
00008E2A 09 23 00 20 <      		r1-=	0x2000
00008E2C 19 D3 C8 00 <      		[KeyQueueBufPtr] = r1 
                     <      	?L_KeyTimeOver:
00008E2E 90 9A       <      		retf
                     <      	
                     <      	//*****************************************************************************/
                     <      	// Purpose : Keyboard Scanner State Machine                                   */
                     <      	//                 F_StartKeyScan                                             */
                     <      	//                        \|/      F_ReScanKey <-----+                        */
                     <      	//                 Scan R-option   (F_KeyCodeMapping)|                        */
                     <      	//                        \|/         \|/            |                        */
                     <      	//                 +---> F_PrepareNextScanLine       |                        */
                     <      	//                 |          \|/                    |                        */
                     <      	//                 |     F_ReadKeyBeforeBounce       |                        */
                     <      	//                 |          \|/                    |                        */
                     <      	//                 |     F_ReadKeyAfterBounce        |                        */
                     <      	//                 |          \|/                    |                        */
                     <      	//                 |     F_NextScanLine              |                        */
                     <      	//                 | no       \|/               yes  |                        */
                     <      	//                 +---- the last scan line ? -------+                        */
                     <      	//*****************************************************************************/
                     <      	//-----------------------------------------------------------------------
                     <      	// State and vector definitions for keyboard scan
                     <      	// The format is as follows:
                     <      	// V_StateVector	   .DW      Address of Subroutine
                     <      	// .const  S_StateName	      = State Number
                     <      	V_KeyScan:
00008E2F 3A 8E       <      	V_ReadKeyBeforeBounce:     .DW      F_ReadKeyBeforeBounce
                     <      	.const   S_ReadKeyBeforeBounce      = (V_ReadKeyBeforeBounce-V_KeyScan)*256
00008E30 4F 8E       <      	V_ReadKeyAfterBounce:      .DW      F_ReadKeyAfterBounce
                     <      	.const   S_ReadKeyAfterBounce       = (V_ReadKeyAfterBounce-V_KeyScan)*256
00008E31 91 8E       <      	V_KeyCodeMapping:	  .DW      F_KeyCodeMapping
                     <      	.const   S_KeyCodeMapping	   = (V_KeyCodeMapping-V_KeyScan)*256
                     <      	//----------------------------------------------------------------------------//
                     <      	F_KeyScan:
00008E32 11 93 C2 00 <      		r1 =	[KeyScanFlag]
00008E34 79 93       <      		r1 =	r1 lsr 4
00008E35 79 93       <      		r1 =	r1 lsr 4
00008E36 4F B2       <      		r1&=	0x000F
00008E37 09 03 2F 8E <      		r1+=	V_KeyScan
00008E39 C1 9E       <      		pc =	[r1]
                     <      	//----------------------------------------------------------------------------//
                     <      	F_ReadKeyBeforeBounce:	      		//the first read
00008E3A 11 93 00 70 <      		r1 =	[P_IOA_Data]
00008E3C 5F 82       <      		r1^=	0x001F
00008E3D 5F B2       <      		r1&=	0x001F			//b0~4 of r1 is result
00008E3E 12 95 C2 00 <      		r2 =	[KeyScanFlag]
00008E40 0A B5 00 F0 <      		r2&=	0xF000
00008E42 0A A5 00 01 <      		r2|=	S_ReadKeyAfterBounce
00008E44 1A A3 C2 00 <      		[KeyScanFlag] = r2|r1
00008E46 11 93 C8 00 <      		r1 =	[KeyQueueBufPtr]     //send debounce time
00008E48 09 B3 FF 1F <      		r1&=	0x1FFF
00008E4A 09 A3 00 60 <      		r1|=	KeyDebounceTime
00008E4C 19 D3 C8 00 <      		[KeyQueueBufPtr] = r1
00008E4E 90 9A       <      		retf
                     <      	//----------------------------------------------------------------------------//
                     <      	F_ReadKeyAfterBounce:			//the second read after bounce time
00008E4F 11 93 C8 00 <      		r1 =	[KeyQueueBufPtr]
00008E51 09 C3 00 E0 <      		test    r1,0xE000
00008E53 02 5E       <      		jz      ?L_BounceTimeOut
00008E54 80 FE 8B 8E <      		goto	?L_ReadKeyOver
                     <      	?L_BounceTimeOut:
00008E56 0D 9B 00 70 <      		bp =	P_IOA_Data
00008E58 C5 92       <      		r1 =	[bp]
00008E59 5F 82       <      		r1^=	0x001F
00008E5A 5F B2       <      		r1&=	0x001F			//b0~4 of R1 is result
00008E5B 12 95 C2 00 <      		r2 =	[KeyScanFlag]
00008E5D 0A B7 1F 00 <      		r3 =	r2 & 0x001F
00008E5F 03 43       <      		cmp     r1,r3
00008E60 0A 4E       <      		jnz	?L_KeyStatusOk		//ignore, not equal
00008E61 7A 9B       <      		bp =	r2 lsr 4
00008E62 7D 9B       <      		bp =	bp lsr 4
00008E63 7D 9B       <      		bp =	bp lsr 4		//the current scan line
00008E64 0D 0B C3 00 <      		bp+=	KeyStatusBuf
00008E66 C5 A6       <      		r3|=	[bp]
00008E67 C5 86       <      		r3^=	[bp]			//'0' -- '1',the corresponding bit is '1'
00008E68 5B 97       <      		r3 =	r3 LSL 4
00008E69 5B A3       <      		r1|=	r3 LSL 4
00008E6A C5 D2       <      		[bp]	= r1
                     <      	?L_KeyStatusOk:
00008E6B 11 93 C2 00 <      		r1 =	[KeyScanFlag]
00008E6D 09 03 00 10 <      		r1+=	0x1000
00008E6F 09 B3 00 F0 <      		r1&=	0xF000
00008E71 09 43 00 50 <      		cmp	r1,0x5000		//have all lines scanned?
00008E73 13 2E       <      		jge	?L_KeyScanLineOver	//check key and scan again
00008E74 40 A2       <      		r1|=	S_ReadKeyBeforeBounce	//check next line
00008E75 19 D3 C2 00 <      		[KeyScanFlag] = r1
                     <      	?L_PrepareNextScanLine:
00008E77 79 93       <      		r1 =	r1 lsr 4
00008E78 79 93       <      		r1 =	r1 lsr 4
00008E79 79 93       <      		r1 =	r1 lsr 4
00008E7A 09 03 8C 8E <      		r1+=	TW_ScanLine
00008E7C C1 92       <      		r1 =	[r1]
00008E7D 40 F1       <      		int	off
00008E7E 12 95 06 70 <      		r2 =	[P_IOB_Buf]
00008E80 0A B5 E0 00 <      		r2&=	0x00E0
00008E82 01 A5       <      		r2|=	r1
00008E83 1A D5 05 70 <      		[P_IOB_Data] = r2		  //Set scan line
00008E85 43 F1       <      		int	fiq,irq
00008E86 04 EE       <      		jmp	?L_ReadKeyOver
                     <      	?L_KeyScanLineOver:
00008E87 09 A3 00 02 <      		r1 |= S_KeyCodeMapping
00008E89 19 D3 C2 00 <      		[KeyScanFlag] = r1
                     <      	?L_ReadKeyOver:
00008E8B 90 9A       <      		retf
                     <      	//-------------------------------------------------------------------------------
                     <      	TW_ScanLine:
00008E8C 1E 00       <      		.DW      0x001F - 0x0001	// IOB0 = 0
00008E8D 1D 00       <      		.DW      0x001F - 0x0002	// IOB1 = 0
00008E8E 1B 00       <      		.DW      0x001F - 0x0004	// IOB2 = 0
00008E8F 17 00       <      		.DW      0x001F - 0x0008	// IOB3 = 0
00008E90 0F 00       <      		.DW      0x001F - 0x0010	// IOB4 = 0
                     <      	//----------------------------------------------------------------------------//
                     <      	F_KeyCodeMapping:
00008E91 40 92       <      		r1 =	0x0000			//r1 - column number
                     <      	?L_SearchKeyLoop:
00008E92 09 0B C3 00 <      		bp =	r1+KeyStatusBuf
00008E94 C5 94       <      		r2 =	[bp]
00008E95 0A C5 00 1F <      		test	r2,0x1F00
00008E97 05 4E       <      		jnz	?L_FindKeyChanged	//key is changed to be pressed from release
00008E98 41 02       <      		r1+=	0x0001
00008E99 45 42       <      		cmp	r1,0x0005
00008E9A 49 3E       <      		jl	?L_SearchKeyLoop
00008E9B 80 FE E2 8E <      		goto	?L_ReStartScanKey
                     <      	?L_FindKeyChanged:			//r1 - column number
00008E9D 7A 97       <      		r3 =	r2 lsr 4
00008E9E 7B 97       <      		r3 =	r3 lsr 4
00008E9F 5F B6       <      		r3&=	0x001F
00008EA0 5F 86       <      		r3^=	0x001F
00008EA1 02 B7       <      		r3&=	r2
00008EA2 02 5E       <      		jz	?L_ChangePressSameKey
00008EA3 80 FE E2 8E <      		goto	?L_ReStartScanKey
                     <      	?L_ChangePressSameKey:
                     <      	//----------------------------------------------------------------------------
                     <      	//Check if other key is pressed
00008EA5 0C 99 C3 00 <      		r4 = KeyStatusBuf
                     <      	?L_SearchOtherKeyLoop:
00008EA7 05 49       <      		cmp	r4,bp
00008EA8 05 5E       <      		jz      ?L_SearchNextLine
00008EA9 C4 96       <      		r3 =	[r4]
00008EAA 5F C6       <      		test    r3,0x001F
00008EAB 02 5E       <      		jz	?L_SearchNextLine
00008EAC 80 FE E2 8E <      		goto	?L_ReStartScanKey	//other key is still pressed
                     <      	?L_SearchNextLine:
00008EAE 41 08       <      		r4+=	0x0001
00008EAF 0C 49 C8 00 <      		cmp     r4,KeyStatusBuf+0x0005
00008EB1 4B 3E       <      		jl	?L_SearchOtherKeyLoop
                     <      	//----------------------------------------------------------------------------
00008EB2 0D 9B F4 8E <      		bp =	TB_KeyNumber		//r2 - key status buffer's value
00008EB4 01 0B       <      		bp+=	r1
00008EB5 C5 96       <      		r3 =	[bp]
00008EB6 0A B5 00 1F <      		r2&=	0x1F00
00008EB8 4A 95       <      		r2 =	r2 LSL 2
                     <      	?L_GetRowNumberLoop:
00008EB9 41 26       <      		r3-=	0x0001
00008EBA 42 95       <      		r2 =	r2 LSL 1
00008EBB 43 6E       <      		jpl	?L_GetRowNumberLoop
00008EBC 0A C5 FF 7F <      		test	r2,0x7FFF
00008EBE 02 5E       <      		jz	?L_NoOtherKey
00008EBF 80 FE E2 8E <      		goto	?L_ReStartScanKey
                     <      	?L_NoOtherKey:
00008EC1 0B 07 F9 8E <      		r3+=	TB_KeyCode

⌨️ 快捷键说明

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