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

📄 display.s

📁 已经上传的YF-320240-3.5寸彩屏(可由单片机控制)的测试程序。主CPU为MEGA128
💻 S
📖 第 1 页 / 共 5 页
字号:
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall cmp32f
	brge X4
	xjmp L46
X4:
	.dbline 153
; 	 {   
	.dbline 154
; 	     if(x1>x2)//交换两者数据,保证x1<x2
	cp R20,R10
	cpc R21,R11
	brsh L48
	.dbline 155
; 		 {
	.dbline 156
; 		     x = x1;
	movw R12,R10
	.dbline 157
; 			 x1 = x2;
	movw R10,R20
	.dbline 158
; 			 x2 = x;
	movw R20,R12
	.dbline 159
; 		 }
L48:
	.dbline 160
; 	     for(x=x1;x<x2;x++)
	movw R12,R10
	xjmp L53
L50:
	.dbline 161
; 	     { 
	.dbline 162
; 		     y = (ey-sy)*(x-sx)/(ex-sx)+sy;
	movw R30,R28
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 4
	ldd R2,z+8
	ldd R3,z+9
	ldd R4,z+10
	ldd R5,z+11
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall sub32fs
	ldi R16,<L45
	ldi R17,>L45
	xcall elpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R16,R12
	lsr R17
	ror R16
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32fs
	movw R16,R12
	andi R16,1
	andi R17,0
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall add32fs
	movw R30,R28
 ; stack offset 8
	ldd R2,z+8
	ldd R3,z+9
	ldd R4,z+10
	ldd R5,z+11
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall sub32fs
	xcall empy32fs
	movw R30,R28
 ; stack offset 4
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 8
	ldd R2,z+8
	ldd R3,z+9
	ldd R4,z+10
	ldd R5,z+11
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall sub32fs
	xcall div32fs
	movw R30,R28
 ; stack offset 4
	ldd R2,z+8
	ldd R3,z+9
	ldd R4,z+10
	ldd R5,z+11
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall add32f
	movw R30,R28
	std z+16,R16
	std z+17,R17
	std z+18,R18
	std z+19,R19
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L56
	ldi R17,>L56
	xcall elpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall cmp32f
	brlt L54
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L56
	ldi R17,>L56
	xcall elpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall sub32f
	xcall fp2int
	movw R24,R16
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R14,R24
	xjmp L55
L54:
	movw R30,R28
	ldd R16,z+16
	ldd R17,z+17
	ldd R18,z+18
	ldd R19,z+19
	xcall fp2int
	movw R14,R16
L55:
	mov R10,R14
	.dbline 163
	sts 32769,R10
	.dbline 164
	sts 32768,R12
	.dbline 165
	movw R2,R12
	mov R2,R3
	clr R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	sts 32770,R2
	.dbline 166
	ldd R0,y+36
	sts 32771,R0
	.dbline 167
	mov R24,R10
	subi R24,255    ; addi 1
	sts 32769,R24
	.dbline 168
	sts 32768,R12
	.dbline 169
	movw R2,R12
	mov R2,R3
	clr R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	sts 32770,R2
	.dbline 170
	sts 32771,R0
	.dbline 171
L51:
	.dbline 160
	movw R24,R12
	adiw R24,1
	movw R12,R24
L53:
	.dbline 160
	cp R12,R20
	cpc R13,R21
	brsh X5
	xjmp L50
X5:
	.dbline 172
; 		     Y_ADDR = y;
;              X_ADDR = x;
;              CMD = ( x/256)<<2;//TFT板为CMD = ( x/256)<<2;,CSTN板为CMD = (( x/256)<<6)|0x04;
; 		     DAT = color;
; 		     Y_ADDR = y+1;
;              X_ADDR = x;
;              CMD = ( x/256)<<2;//TFT板为CMD = ( x/256)<<2;,CSTN板为CMD = (( x/256)<<6)|0x04;
; 		     DAT = color;
;          }
;      }
	xjmp L47
L46:
	.dbline 174
; 	 else
; 	 {
	.dbline 175
; 	     if(y1>y2)//交换两者数据,保证y1<y2
	ldd R0,y+34
	ldd R16,y+30
	cp R0,R16
	brsh L57
	.dbline 176
; 		 {
	.dbline 177
; 		     y = y1;
	mov R10,R16
	.dbline 178
; 			 y1 = y2;
	std y+30,R0
	.dbline 179
; 			 y2 = y;
	std y+34,R10
	.dbline 180
; 		 }
L57:
	.dbline 181
; 	     for(y=y1;y<y2;y++)
	ldd R10,y+30
	xjmp L62
L59:
	.dbline 182
; 	     { 
	.dbline 183
; 		     x = (ex-sx)*(y-sy)/(ey-sy)+sx;
	movw R30,R28
	ldd R2,z+8
	ldd R3,z+9
	ldd R4,z+10
	ldd R5,z+11
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 4
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall sub32fs
	mov R16,R10
	clr R17
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R30,R28
 ; stack offset 8
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall sub32fs
	xcall empy32fs
	movw R30,R28
 ; stack offset 4
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 8
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall sub32fs
	xcall div32fs
	movw R30,R28
 ; stack offset 4
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall add32f
	movw R30,R28
	std z+16,R16
	std z+17,R17
	std z+18,R18
	std z+19,R19
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L56
	ldi R17,>L56
	xcall elpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall cmp32f
	brlt L63
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L56
	ldi R17,>L56
	xcall elpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall sub32f
	xcall fp2int
	movw R24,R16
	subi R24,0  ; offset = 32768
	sbci R25,128
	movw R14,R24
	xjmp L64
L63:
	movw R30,R28
	ldd R16,z+16
	ldd R17,z+17
	ldd R18,z+18
	ldd R19,z+19
	xcall fp2int
	movw R14,R16
L64:
	movw R12,R14
	.dbline 184
	sts 32769,R10
	.dbline 185
	sts 32768,R12
	.dbline 186
	movw R2,R12
	mov R2,R3
	clr R3
	lsl R2
	rol R3
	lsl R2
	rol R3
	sts 32770,R2
	.dbline 187
	ldd R0,y+36
	sts 32771,R0
	.dbline 188
	nop
	.dbline 189
	nop
	.dbline 190
	sts 32771,R0
	.dbline 195
L60:
	.dbline 181
	inc R10
L62:
	.dbline 181
	ldd R0,y+34
	cp R10,R0
	brsh X6
	xjmp L59
X6:
	.dbline 196
L47:
	.dbline -2
L44:
	adiw R28,20
	xcall pop_gset5
	adiw R28,2
	.dbline 0 ; func end
	ret
	.dbsym l ey 12 D
	.dbsym l ex 8 D
	.dbsym l sy 4 D
	.dbsym l sx 0 D
	.dbsym r y 10 c
	.dbsym r x 12 i
	.dbsym l color 36 c
	.dbsym l y2 34 c
	.dbsym r x2 20 i
	.dbsym l y1 30 c
	.dbsym r x1 10 i
	.dbend
	.dbfunc e Dis_Command _Dis_Command fV
	.dbstruct 0 17 Command
	.dbfield 0 x i
	.dbfield 2 y c
	.dbfield 3 width i
	.dbfield 5 width_e i
	.dbfield 7 lenth c
	.dbfield 8 lenth_e c
	.dbfield 9 color c
	.dbfield 10 str pc
	.dbfield 12 english pc
	.dbfield 14 string_color c
	.dbfield 15 font c
	.dbfield 16 cursor_color c
	.dbend
;            cmd -> R20,R21
	.even
_Dis_Command::
	xcall push_gset1
	movw R20,R16
	sbiw R28,7
	.dbline -1
	.dbline 205
; 		     Y_ADDR = y;
;              X_ADDR = x;
;              CMD = ( x/256)<<2;//TFT板为CMD = ( x/256)<<2;,CSTN板为CMD = (( x/256)<<6)|0x04;
; 		     DAT = color;
; 			 _NOP();
; 			 _NOP();
; 			 DAT = color;
; 		     //Y_ADDR = y;
;              //X_ADDR = x+1;
;              //CMD = ( x/256)<<2;//TFT板为CMD = ( x/256)<<2;,CSTN板为CMD = (( x/256)<<6)|0x04;
; 		     //DAT = color; 
;          }
; 	 }		 
; }
; 
; /*
;     功能:显示命令按键
; 	参数:struct Command
; 	
; */
; void Dis_Command(struct Command cmd)
; {
	.dbline 206
;     if((cursor.x >cmd.x)&&(cursor.y >cmd.y)&&((cursor.x-cmd.x)<cmd.width)&&((cursor.y - cmd.y) < cmd.lenth))
	movw R30,R20
	ldd R2,z+0
	ldd R3,z+1
	lds R4,_cursor
	lds R5,_cursor+1
	cp R2,R4
	cpc R3,R5
	brlo X9
	xjmp L66
X9:
	ldd R4,z+2
	clr R5
	lds R6,_cursor+2
	clr R7
	cp R4,R6
	cpc R5,R7
	brlt X10
	xjmp L66
X10:
	lds R6,_cursor
	lds R7,_cursor+1
	sub R6,R2
	sbc R7,R3
	movw R30,R20
	ldd R2,z+3
	ldd R3,z+4
	cp R6,R2
	cpc R7,R3
	brlo X11
	xjmp L66
X11:
	lds R2,_cursor+2
	clr R3
	sub R2,R4
	sbc R3,R5
	movw R30,R20
	ldd R4,z+7
	clr R5
	cp R2,R4
	cpc R3,R5
	brlt X12
	xjmp L66
X12:
	.dbline 207
; 	{
	.dbline 208
; 	    if((cmd.width >0)&&(cmd.lenth>0))
	movw R30,R20
	ldd R2,z+3
	ldd R3,z+4
	tst R2
	brne X7
	tst R3
	breq L70
X7:
	clr R2
	movw R30,R20
	ldd R3,z+7
	cp R2,R3
	brsh L70
	.dbline 209
; 	    {
	.dbline 210
; 	        Dis_Rect(cmd.x,cmd.y,cmd.width,cmd.lenth,cmd.cursor_color);
	movw R30,R20
	ldd R2,z+16
	std y+4,R2
	movw R30,R20
	ldd R2,z+7
	std y+2,R2
	movw R30,R20
	ldd R2,z+3
	ldd R3,z+4
	std y+1,R3
	std y+0,R2
	movw R30,R20
	ldd R18,z+2
	movw R30,R20
	ldd R16,z+0
	ldd R17,z+1
	xcall _Dis_Rect
	.dbline 211
; 	    } 
L70:
	.dbline 212
; 		if(cmd.font == FLAG)
	movw R30,R20
	ldd R24,z+15
	cpi R24,2
	brne L72
	.dbline 213
; 		{
	.dbline 214
; 		   Dis_Flag(cmd.x+5,cmd.y+5,*cmd.str - 0x30,cmd.string_color,cmd.color);
	movw R30,R20
	ldd R2,z+9
	clr R3
	std y+5,R3
	std y+4,R2
	movw R30,R20
	ldd R2,z+14
	std y+2,R2
	movw R30,R20
	ldd R26,z+10
	ldd R27,z+11
	ld R24,x
	clr R25
	sbiw R24,48
	std y+1,R25
	std y+0,R24
	movw R30,R20
	ldd R18,z+2
	subi R18,251    ; addi 5
	movw R30,R20
	ldd R16,z+0
	ldd R17,z+1
	subi R16,251  ; offset = 5
	sbci R17,255
	xcall _Dis_Flag
	.dbline 215
; 		}
	xjmp L67
L72:
	.dbline 217
; 		else
; 		{
	.dbline 218
; 	      Display(cmd.x+5,cmd.y+5,cmd.str,cmd.font,cmd.string_color,cmd.cursor_color);
	movw R30,R20
	ldd R2,z+16
	std y+6,R2
	movw R30,R20
	ldd R2,z+14
	std y+4,R2
	movw R30,R20
	ldd R2,z+15
	std y+2,R2
	movw R30,R20
	ldd R2,z+10
	ldd R3,z+11
	std y+1,R3
	std y+0,R2
	movw R30,R20
	ldd R18,z+2
	subi R18,251    ; addi 5
	movw R30,R20
	ldd R16,z+0
	ldd R17,z+1
	subi R16,251  ; offset = 5
	sbci R17,255
	xcall _Display
	.dbline 219
; 		}  
	.dbline 220
; 	} 
	xjmp L67
L66:
	.dbline 222
; 	else
; 	{
	.dbline 223
;         if((cmd.width >0)&&(cmd.lenth>0))
	movw R30,R20
	ldd R2,z+3
	ldd R3,z+4
	tst R2
	brne X8
	tst R3
	breq L74
X8:
	clr R2
	movw R30,R20
	ldd R3,z+7
	cp R2,R3
	brsh L74
	.dbline 224
; 	    {
	.dbline 225
; 	        Dis_Rect(cmd.x,cmd.y,cmd.width,cmd.lenth,cmd.color);
	movw R30,R20
	ldd R2,z+9
	std y+4,R2
	movw R30,R20
	ldd R2,z+7
	std y+2,R2
	movw R30,R20
	ldd R2,z+3
	ldd R3,z+4
	std y+1,R3
	std y+0,R2
	movw R30,R20
	ldd R18,z+2
	movw R30,R20
	ldd R16,z+0
	ldd R17,z+1
	xcall _Dis_Rect
	.dbline 226
; 	    } 
L74:
	.dbline 227
; 		if(cmd.font == FLAG)
	movw R30,R20
	ldd R24,z+15
	cpi R24,2
	brne L76
	.dbline 228
; 		{
	.dbline 229
; 		   Dis_Flag(cmd.x+5,cmd.y+5,*cmd.str - 0x30,cmd.string_color,cmd.color);
	movw R30,R20
	ldd R2,z+9
	clr R3
	std y+5,R3
	std y+4,R2
	movw R30,R20
	ldd R2,z+14
	std y+2,R2
	movw R30,R20
	ldd R26,z+10
	ldd R27,z+11
	ld R24,x
	clr R25
	sbiw R24,48
	std y+1,R25
	std y+0,R24
	movw R30,R20
	ldd R18,z+2
	subi R18,251    ; addi 5
	movw R30,R20
	ldd R16,z+0
	ldd R17,z+1
	subi R16,251  ; offset = 5
	sbci R17,255
	xcall _Dis_Flag
	.dbline 230
; 		}
	xjmp L77
L76:
	.dbline 232
; 		else
; 		{
	.dbline 233
; 	       Display(cmd.x+5,cmd.y+5,cmd.str,cmd.font,cmd.string_color,cmd.color);
	movw R30,R20
	ldd R2,z+9
	std y+6,R2
	movw R30,R20
	ldd R2,z+14
	std y+4,R2
	movw R30,R20
	ldd R2,z+15
	std y+2,R2
	movw R30,R20
	ldd R2,z+10
	ldd R3,z+11
	std y+1,R3
	std y+0,R2
	movw R30,R20
	ldd R18,z+2
	subi R18,251    ; addi 5
	movw R30,R20
	ldd R16,z+0
	ldd R17,z+1
	subi R16,251  ; offset = 5
	sbci R17,255
	xcall _Display
	.dbline 234
; 		}
L77:
	.dbline 235
L67:
	.dbline -2
L65:
	adiw R28,7
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r cmd 20 pS[Command]
	.dbend
	.area lit(rom, con, rel)
_DotCursor::
	.byte 255,192
	.byte 128,128
	.byte 129,0
	.byte 130,0
	.byte 129,0
	.byte 128,128
	.byte 144,64
	.byte 168,32
	.byte 196,16
	.byte 130,8
	.byte 1,4
	.byte 0,136
	.byte 0,'P
	.byte 0,32
	.byte 0,0
	.byte 0,0
	.byte 1,128
	.byte 3,192
	.byte 6,96
	.byte 12,48
	.byte 24,24
	.byte 48,12
	.byte 63,252
	.byte 1,128
	.byte 1,128
	.byte 1,128
	.byte 1,128
	.byte 1,128
	.byte 1,128
	.byte 1,128
	.byte 1,128
	.byte 1,128
	.byte 0,0
	.byte 0,0
	.byte 0,96
	.byte 0,'p
	.byte 0,'X
	.byte 0,'L
	.byte 0,'F
	.byte 255,195
	.byte 255,195
	.byte 0,'F

⌨️ 快捷键说明

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