DATAS SEGMENT;此处输入数据段代码 本程序不高效因为每次在坠落后判断若干次是否满行,没有用记录满行得方式因为是在太无聊了没完成!!
fdot	 	db 	0		;随机产生方块形状的标志
dot1c 		dw	50		
dot1r 		dw 	50
BlockXR		dw	0
rounds		dw	?
BlockXC		dw	0
index		db	0
times		db	2
bottom		db	?
color		db	15
color2		db 14
clrrow		dw 	?
zhengshu	db	?
hang		dw	?
lie			dw	?
scohang		dw	?
wei			db	?
weishu		db	?
gameover	db	'YOU ARE DIED!','$'
pianyi		dw	?
scolie		dw	?
max			dw	19
INTFLAG		db	1
cxx			dw	?
string1c	dw	120,121,122,123,120,120,121,122,123,123,123,122,121,120
			dw	125,126,127,125,125,125,125,126,127
			dw	129,130,131,132,129,132,129,132,129,132,129,130,131,132
			dw	134,135,136,137,134,137,134,135,136,137,134,134,137,137
			dw	139,140,141,142,139,139,140,141,142,139,139,140,141,142
string1r	dw 	140,140,140,140,141,142,142,142,142,143,144,144,144,144
			dw	140,140,140,141,142,143,144,144,144
			dw	140,140,140,140,141,141,142,142,143,143,144,144,144,144
			dw	140,140,140,140,141,141,142,142,142,142,143,144,143,144
			dw	140,140,140,140,141,142,142,142,142,143,144,144,144,144
score0c		dw	139,140,141,142,139,142,139,142,139,142,139,140,141,142
			dw  134,135,136,137,134,137,134,137,134,137,134,135,136,137
			dw	129,130,131,132,129,132,129,132,129,132,129,130,131,132
score0r		dw	147,147,147,147,148,148,149,149,150,150,151,151,151,151
			dw  147,147,147,147,148,148,149,149,150,150,151,151,151,151
			dw	147,147,147,147,148,148,149,149,150,150,151,151,151,151
score1c		dw	142,142,142,142,142
			dw	137,137,137,137,137
			dw	132,132,132,132,132
score1r		dw	147,148,149,150,151
			dw	147,148,149,150,151
			dw	147,148,149,150,151
score2c		dw	139,140,141,142,142,139,140,141,142,139,139,140,141,142
			dw	134,135,136,137,137,134,135,136,137,134,134,135,136,137
			dw	129,130,131,132,132,129,130,131,132,129,129,130,131,132
score2r		dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151
score3c		dw	139,140,141,142,142,139,140,141,142,142,139,140,141,142
			dw	134,135,136,137,137,134,135,136,137,137,134,135,136,137
			dw	129,130,131,132,132,129,130,131,132,132,129,130,131,132
score3r		dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151
score4c		dw	139,139,139,140,141,142,142,142,142,142
			dw	134,134,134,135,136,137,137,137,137,137
			dw	129,129,129,130,131,132,132,132,132,132
score4r		dw	147,148,149,149,149,149,147,148,150,151
			dw	147,148,149,149,149,149,147,148,150,151
			dw	147,148,149,149,149,149,147,148,150,151
score5c		dw	139,140,141,142,139,139,140,141,142,142,139,140,141,142
			dw	134,135,136,137,134,134,135,136,137,137,134,135,136,137
			dw	129,130,131,132,129,129,130,131,132,132,129,130,131,132
score5r		dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151
score6c		dw	139,140,141,142,139,139,140,141,142,142,139,140,141,142,139
			dw	134,135,136,137,134,134,135,136,137,137,134,135,136,137,134
			dw	129,130,131,132,129,129,130,131,132,132,129,130,131,132,129
score6r		dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151,150
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151,150
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151,150
score7c		dw	139,140,141,142,142,142,142,142
			dw	134,135,136,137,137,137,137,137
			dw	129,130,131,132,132,132,132,132
score7r		dw	147,147,147,147,148,149,150,151
			dw	147,147,147,147,148,149,150,151
			dw	147,147,147,147,148,149,150,151
score8c		dw	139,140,141,142,139,139,140,141,142,142,139,140,141,142,139,142
			dw	134,135,136,137,134,134,135,136,137,137,134,135,136,137,134,137
			dw	129,130,131,132,129,129,130,131,132,132,129,130,131,132,129,132
score8r		dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151,150,148
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151,150,148
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151,150,148
score9c		dw	139,140,141,142,139,139,140,141,142,142,139,140,141,142,142
			dw	134,135,136,137,134,134,135,136,137,137,134,135,136,137,137
			dw	129,130,131,132,129,129,130,131,132,132,129,130,131,132,132
score9r		dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151,148
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151,148
			dw	147,147,147,147,148,149,149,149,149,150,151,151,151,151,148
SnakeType	db	0
flag1		db	0
score 		dw	0
oflag		db	0
leftflag	db	0
rightflag	db 	0
BlockBufR 	dw	5 dup (0)
BlockBufC	dw	5 dup (0)
BlockBuf2R 	dw	5 dup (0)
BlockBuf2C	dw	5 dup (0)
BlockBuf3R 	dw	5 dup (0)
BlockBuf3C	dw	5 dup (0)
fullbuf		db	20 dup (0)
Block0c		dw	65,71,77,83		;69,73,77,81
Block0r		dw	53,53,53,53
Block1c		dw	77,83,77,83		;73,77,73,77
Block1r		dw	53,53,59,59		;53,53,57,57
Block2c		dw	77,77,83,83		;73,73,77,77
Block2r		dw	53,59,59,65		;53,57,57,61
Block3c		dw	77,77,83,83		;73,73,77,77
Block3r		dw	59,65,53,59		;57,61,53,57
Block4c		dw	77,77,77,83		;73,73,73,77
Block4r		dw	53,59,65,59		;53,57,61,57
Block5c		dw	77,77,77,83		;73,73,73,77
Block5r		dw	53,59,65,65		;53,57,61,61
Block6c		dw	77,83,83,83		;73,77,77,77
Block6r		dw	65,53,59,65		;61,53,57,61
doutable	db	200 dup (0) ;22*12
DATAS ENDS
;STACKS SEGMENT
    ;此处输入堆栈段代码
;STACKS ENDS
CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS
main proc far
START:
    	MOV AX,DATAS
    	MOV DS,AX
    	MOV AH,00	;图形模式
		MOV AL,0DH
		INT 10H
		MOV AH,0bH	;设背景色
		MOV BH,00
		MOV BL,00
		INT 10H
		MOV AH,0bH	;设调色板
		MOV BH,01H
		MOV BL,1
		INT 10H  ;此处输入代码段代码
  		MOV BX,60
  		MOV DX,120	
  		MOV AL,8
  		CALL dFrame		;画主窗体
  		CALL getRam		;生成方块形状
  		CALL MovBuff	;初始形状入缓冲区
  		CALL getRam		;生成预览形状
  		CALL MovPreBuf	;预览形状入缓冲区
  		CALL DrawString		;画分数字符
		CALL printscore	;打印分数值
MainProc:
		CALL ChangeShape
Int1A:
		MOV AH,02H
		INT 1AH
		AND DH,0fh
		cmp dh,INTFLAG
		JZ 	DoDrop
		JMP ChangeColor
DoDrop:
		CALL DropBlock
		INC INTFLAG
		CMP INTFLAG,10
		JNZ Int1A
		MOV INTFLAG,0
		JMP Int1A
ChangeColor:
		;AND COLOR,0FFH
		;CMP COLOR,0
		;JNZ undo0
		;INC COLOR
undo0:
		MOV	AL,COLOR
		;INC	COLOR
		CALL DrawBlock
		MOV AL,7			;1浅蓝2暗粉红3暗白4暗大红5暗粉红6暗棕7暗白8超暗白9亮蓝10亮绿11亮浅蓝12亮枣红13亮粉红14亮黄15亮白
		CALL DrawPreview
		CMP bottom,1		;触底
		JNZ UnDroped
		MOV AL,0
		CALL DrawPreview	;ClrPreview
		CALL StuffTable	
		CALL ExchangeBuf	;第一个方块降落后,从预览取方块
		CMP max,0
		JZ Over
		CALL getram
		CALL MovPreBuf
		MOV bottom,0
UnDroped:
		CALL delay
		MOV AL,00
		CALL DrawBlock	;ClrBlock
		JMP MainProc
Over:	
		MOV AH,9
		MOV DX,OFFSET GameOver
		INT 21H
		JMP $
		RET
main endp
MovPreBuf 	proc near	
		push ax
		push bx
		push cx
		push di
		push si
		mov bx,2
		mov cx,4
		mov si,BlockXR
		mov di,BlockXC
ooooo5:	
		mov ax,[si]
		mov BlockBuf3R[bx],ax
		mov ax,[di]
		mov BlockBuf3C[bx],ax
		add bx,2
		add si,2
		add di,2
		loop ooooo5
		pop si
		pop di
		pop cx
		pop bx
		pop ax 
		ret
MovPreBuf	endp
ExchangeBuf	proc	near
		push ax
		push cx
		push si
		mov si,0
		mov cx,5
ooooo4:
		mov ax,BlockBuf3r[si]
		mov BlockBufR[si],ax
		mov ax,BlockBuf3C[si]
		mov BlockBufC[si],ax	
		add si,2
		loop ooooo4
		pop si
		pop cx
		pop ax
		ret
ExchangeBuf	endp
DrawString	proc	near	;打印分数字符
		push ax
		push cx
		push dx
		push si
		mov cx,65
		mov al,Color2
		mov si,0
ooooo1:	
		push cx
		mov ah,0ch
		mov cx,string1c[si]
		mov dx,string1r[si]
		int 10h
		add si,2
		pop cx
		loop ooooo1
		pop si
		pop dx
		pop cx
		pop ax
		ret 
DrawString	endp
Score?	proc near	;判断当前分数值便于打印
		push ax
		push bx
		push cx
		push dx
		push si
		cmp score,9
		ja duonum
		mov weishu,0
		mov ax,score
		mov bl,10
		div bl
		mov wei,ah
		call printscore
		jmp exit21
duonum:	
		cmp score,99
		ja thrnum
		mov ax,score
		mov bl,10
		div bl
		mov wei,ah
		mov weishu,0
		call printscore
		mov weishu,1
		mov wei,al
		call printscore
		jmp exit21
thrnum:
		cmp score,999
		ja exit21
		mov ax,score
		mov bl,100
		div bl
		mov wei,al
		mov weishu,2
		call printscore
		mov al,ah
		cbw
		mov bl,10
		div bl
		mov wei,ah
		mov weishu,0
		call printscore
		mov weishu,1
		mov wei,al
		call printscore
exit21:
		pop si
		pop dx
		pop cx
		pop bx
		pop ax
		ret
Score?	endp
NumBit proc near	;根据分数有几位确定偏移位置打印分数
		push ax
		push bx
		push cx
		mov ah,0
		mov al,weishu
		mul cl
		mov bl,2
		mul bl
		mov pianyi,ax
		pop cx
		pop bx
		pop ax
		ret
NumBit endp
printscore	proc near	;打印分数值
		push ax
		push cx
		push dx
		push si
sc10:
		mov al,0
		mov cx,16
		call NumBit
		mov si,pianyi
clr8:
		push cx
		mov ah,0ch
		mov cx,score8c[si]
		mov dx,score8r[si]
		int 10h
		add si,2
		pop cx
		loop clr8
		mov al,color2
		cmp wei,0
		jz print0
		cmp wei,1
		jz print1
		cmp wei,2
		jz print2
		cmp wei,3
		jz print3
		cmp wei,4
		jz print4
		cmp wei,5
		jz print5
		cmp wei,6
		jz print6
		cmp wei,7
		jz print7
		cmp wei,8
		jz print8
		cmp wei,9
		jz print9
print0:
		mov cx,14
		call NumBit
		mov si,pianyi
sc0:
		push cx
		mov ah,0ch
		mov cx,score0c[si]
		mov dx,score0r[si]
		int 10h
		add si,2
		pop cx
		loop sc0
		jmp exit20
print1:
		mov cx,5
		call NumBit
		mov si,pianyi
sc1:
		push cx
		mov ah,0ch
		mov cx,score1c[si]
		mov dx,score1r[si]
		int 10h
		add si,2
		pop cx
		loop sc1
		jmp exit20
print2:
		mov cx,14
		call NumBit
		mov si,pianyi
sc2:	push cx
		mov ah,0ch
		mov cx,score2c[si]
		mov dx,score2r[si]
		int 10h
		add si,2
		pop cx
		loop sc2
		jmp exit20
print3:
		mov cx,14
		call NumBit
		mov si,pianyi
sc3:	push cx
		mov ah,0ch
		mov cx,score3c[si]
		mov dx,score3r[si]
		int 10h
		add si,2
		pop cx
		loop sc3
		jmp exit20
print4:
		mov cx,10
		call NumBit
		mov si,pianyi
sc4:
		push cx
		mov ah,0ch
		mov cx,score4c[si]
		mov dx,score4r[si]
		int 10h
		add si,2
		pop cx
		loop sc4
		jmp exit20
print5:
		mov cx,14
		call NumBit
		mov si,pianyi
sc5:
		push cx
		mov ah,0ch
		mov cx,score5c[si]
		mov dx,score5r[si]
		int 10h
		add si,2
		pop cx
		loop sc5
		jmp exit20
print6:
		mov cx,15	
		call NumBit
		mov si,pianyi
sc6:	
		push cx
		mov ah,0ch
		mov cx,score6c[si]
		mov dx,score6r[si]
		int 10h
		add si,2
		pop cx
		loop sc6
		jmp exit20
print7:
		mov cx,8
		call NumBit
		mov si,pianyi
sc7:	
		push cx		
		mov ah,0ch
		mov cx,score7c[si]
		mov dx,score7r[si]
		int 10h
		add si,2
		pop cx
		loop sc7
		jmp exit20
print8:
		mov cx,16
		call NumBit
		mov si,pianyi
sc8:	
		push cx
		mov ah,0ch
		mov cx,score8c[si]
		mov dx,score8r[si]
		int 10h
		add si,2
		pop cx
		loop sc8
		jmp exit20
print9:
		mov cx,15
		call NumBit
		mov si,pianyi
sc9:
		push cx
		mov ah,0ch
		mov cx,score9c[si]
		mov dx,score9r[si]
		int 10h
		add si,2
		pop cx
		loop sc9
		jmp exit20
exit20:
		pop si
		pop dx
	  	pop cx
	   	pop ax
		ret
printscore 	endp
StuffTable	proc near	;填充二维表
		push ax
		push bx
		push cx
		push bp
		push di
		push si
		mov cx,4
		mov si,2
oooo:
		call GetTablexy
		mov di,ax
		inc fullbuf[bp]
		cmp max,bp
		jbe o11
		mov max,bp
o11:	
		mov doutable[di],1
		add si,2
		loop oooo
		mov ax,20
		sub ax,max
		mov cx,ax
		mov bp,19
oooo4:	
		cmp fullbuf[bp],10
		jz full
oooo5:
		dec bp
		loop oooo4
		jmp exit6
full:	
		push cx
		mov fullbuf[bp],0	;注意清哪行BP-1?	;大傻逼只是清楚表面,二维数组你清了吗??????????	
		mov di,bp
		mov si,max
		sub di,si
		mov rounds,di
		mov cx,di
		inc cx
		mov di,bp	;缺少这句di值被改变,减去了si!
		;call printout
		oooo13:	mov al,fullbuf[di-1]
		mov fullbuf[di],al
		;call printout
		dec di
		loop oooo13
		pop cx
		mov ax,bp
		inc ax		;???????????????????问题否?????超出行
		mov bl,10
		mul bl
		dec ax	;(bp+1)*10-1
		mov si,ax
		call clrtable
		mov clrrow,bp
		call clrBlock
		call UpdateTabValue
		call RedrawBlock
		inc score
		call score?
		inc max
		jmp oooo4
exit6:	
		pop si
		pop di
		pop bp
		pop cx
		pop bx
		pop ax
		ret
stuffTable	endp
clrtable	proc near	;清二维表相应值
		push cx
		push si
		mov cx,10
oooo11:	
		mov doutable[si],0
		dec si
		loop oooo11
		pop si
		pop cx
		ret
clrtable	endp
UpdateTabValue	proc near
		push ax
		push bx
		push cx
		push si
		mov ax,rounds
		mov bl,10
		mul bl
		mov cxx,ax
		mov cx,cxx
		mov ax,clrrow
		mov bl,10
		mul bl
		dec ax	;bp*10-1
		mov si,ax
oooo6:
		cmp doutable[si],1
		jz mdown
oooo7:	
		dec si
		loop oooo6
		jmp exit8
mdown:
		mov doutable[si],0
		mov doutable[si+10],1
		jmp oooo7
exit8:
		pop si
		pop cx
		pop bx
		pop ax
		ret
UpdateTabValue	endp
RedrawBlock	proc near	;满行清除后重画方块
		push ax
		push bx
		push cx
		push si
		mov cx,cxx
		mov ax,clrrow
		inc ax		;???????????????????问题否?????超出行
		mov bl,10
		mul bl
		dec ax	;(bp+1)*10-1
		mov si,ax
oooo9:	
		cmp doutable[si],1
		jz godraw
oooo10:	
		dec si
		loop oooo9
		jmp exit10
godraw:	
		call FetchXY
		call DoDraw
		jmp oooo10
exit10:
		pop si
		pop cx
		pop bx
		pop ax
		ret
RedrawBlock	endp
FetchXY	proc	;重画时,根据二维表中的坐标转换为实际窗体坐标
		push ax
		push bx
		mov ax,si
		mov bl,10
		div bl
		mov zhengshu,al
		mov al,ah
		mov bl,6
		mul bl
		add ax,53
		mov lie,ax
		mov al,zhengshu
		mul bl
		add ax,53
		mov hang,ax
		pop bx
		pop ax
		ret
FetchXY	endp
DoDraw	proc	near
		push ax
		push bx
		push cx
		push dx
		push di
		mov di,hang
		mov bx,lie
		mov al,01h
		dec bx
		sub di,2
		mov cx,3
o7oo:	
		push cx
		mov ah,0ch
		mov dx,di
		mov cx,bx
		int 10h
		cmp flag1,0
		jnz nf4o
		inc bx
		pop cx
		loop o7oo
		mov cx,3
		inc di
		inc flag1
		jmp o7oo
nf4o:	
		cmp flag1,1
		jnz nf5o
		inc di
		pop cx
		loop o7oo
		mov cx,3
		dec bx
		inc flag1
		jmp o7oo
nf5o:
		cmp flag1,2
		jnz nf6o	
		dec bx
		pop cx
		loop o7oo
		mov cx,3
		dec di
		inc flag1
		jmp o7oo
nf6o:
		dec di
		pop cx
		loop o7oo
		add di,2
		add bx,2
		mov flag1,0
		pop di
		pop dx
		pop cx
		pop bx
		pop ax
		ret
DoDraw	endp
ClrBlock	proc	near	;满行后清方块
		push ax
		push bx
		push cx
		push dx
		push di
		push si
		mov cx,10
		mov si,clrrow
o2oo:	
		push cx
		mov ax,si
		mov bl,6
		mul bl
		add ax,51	;51+(bp-1)*6
		mov di,ax
		mov cx,10
		mov bx,51
		mov al,0
o2o:
		push cx
		inc bx
		mov cx,3
o7o:
		push cx
		mov ah,0ch
		mov dx,di
		mov cx,bx
		int 10h
		cmp flag1,0
		jnz nf4
		inc bx
		pop cx
		loop o7o
		mov cx,3
		inc di
		inc flag1
		jmp o7o
mide2:	
		jmp o2o
nf4:	
		cmp flag1,1
		jnz nf5
		inc di
		pop cx
		loop o7o
		mov cx,3
		dec bx
		inc flag1
		jmp o7o
nf5:	
		cmp flag1,2
		jnz nf6
		dec bx
		pop cx
		loop o7o
		mov cx,3
		dec di
		inc flag1
		jmp o7o
nf6:
		dec di
		pop cx
		loop o7o
		add bx,6
		mov flag1,0
		pop cx
		loop mide2
		pop cx
		dec si
		loop o2oo
		pop si
		pop di
		pop dx
		pop cx
		pop bx
		pop ax
		ret
ClrBlock	endp
GetTablexy 	proc near		;将实际坐标转换为二维表坐标
		push bx
		push dx
		mov ax,BlockBufC[si]
		sub ax,51
		sub ax,2
		mov bl,6		;4>>>>>>>>>>>
		div bl
		mov dx,ax
		mov ax,BlockBufR[si]
		sub ax,51
		sub ax,2
		mov bl,6		;4>>>>>>>>>>>>
		div bl
		mov bp,ax
		mov bl,10
		mul bl
		add ax,dx
		pop dx
		pop bx
		ret		;!!!!!忘了返回!!!!!!
GetTablexy	endp
ifhere 	proc near		;左右下是否有方块
		push ax
		push bx
		push cx
		push di
		push si
		mov cx,4
		mov si,2
			;判断左
oooo1:	
		call GetTablexy
		mov di,ax
		cmp doutable[di-1],1
		jz isleft
		add si,2
		loop oooo1
		jmp isright?
isleft:
		mov leftflag,1			;继续判断有可能被左右夹击
isright?:
		mov cx,4	;判断右
		mov si,2
oooo2:	
		call GetTablexy
		mov di,ax
		cmp doutable[di+1],1
		jz isright
		add si,2
		loop oooo2
		jmp isdown?
isright:
		mov rightflag,1
isdown?:
		mov cx,4
		mov si,2
oooo3:	
		call GetTablexy
		mov di,ax
		cmp doutable[di+10],1
		jz isdown
		add si,2
		loop oooo3
		jmp exit4
isdown:	
		mov bottom,1
exit4:	
		pop si
		pop di
		pop cx
		pop bx
		pop ax	
		ret
ifhere	endp
OutLine?	proc near	;判断是到达边界
		push ax
		push bx
		push cx
		push si
		mov	 cx,4
		mov si,2
ooo1:	
		mov ax,BlockBufC[si]
		sub ax,3
		cmp ax,50		;判断是否左越界
		jbe lexceed
		add si,2
		loop ooo1
		jmp right?
lexceed:
		mov index,1
right?:	
		mov cx,4
		mov si,2
ooo2:	
		mov ax,BlockBufC[si]
		add ax,3
		cmp ax,107	;100	判断是否右越界
		jae rexceed
		add si,2
		loop ooo2
		jmp down?
rexceed:
		mov index,2
down?:
		mov cx,4
		mov si,2
ooo3:
		mov ax,BlockBufR[si]
		add ax,3
		cmp ax,	165	;138	;判断是否下越界
		jae dexceed
		add si,2
		loop ooo3
		jmp exit1
dexceed:	
		mov bottom,1
exit1:
		pop si
		pop cx
		pop bx
		pop ax
		ret
OutLine? 	endp
ChangeShape	proc near		;取变形坐标时,注意偏移量,+104
		push ax
		push bx
		push cx
		push dx
		push si
		mov ah,01h
		int 16h
		jz mide3
		cmp ah,39h
		jnz nstop
		mov ah,0ch	;清空键盘缓冲区	
		mov al,02h
		int 21h
died:
		mov ah,01h
		int 16h
		jz died
		cmp ah,39h
		jnz died
		jmp nsto
nsto:
		mov ah,0ch	;清空键盘缓冲区	
		mov al,02h
		int 21h
nstop:
		cmp ah,48h
		jnz nup
		mov cx,5
		mov si,0
again0:
		mov ax,BlockBufC[si]
		mov BlockBuf2C[si],ax
		mov ax,BlockBufR[si]
		mov BlockBuf2R[si],ax
		add si,2
		loop again0
		mov cx,4
		mov si,2	
oo2:	
		mov ax,BlockBufC[0]
		sub BlockBufC[si],ax
		mov bx,BlockBufR[0]
		sub BlockBufR[si],bx
		sub ax,BlockBufR[si]
		add bx,BlockBufC[si]
		mov BlockBufC[si],ax
		mov BlockBufR[si],bx	;变形即九十度顺时针旋转
		add si,2
		loop oo2
		call OutShape?
		cmp oflag,1
		jz xch
		call ifhere
		cmp leftflag,1
		jz xch
		cmp rightflag,1
		jz xch
		cmp bottom,1
		jz xch
		jmp exit
xch:	
		mov cx,5
		mov si,0
again1:	
		mov ax,BlockBuf2C[si]
		mov BlockBufC[si],ax
		mov ax,BlockBuf2R[si]
		mov BlockBufR[si],ax
		add si,2
		loop again1
		jmp exit
nup:
		cmp ah,4bh 	;left<-
		jnz nleft
		mov index,0	;清越界标志
		mov rightflag,0
		mov bottom,0
		call OutLine?
		cmp index,1
		jz exit
		call ifhere
		cmp leftflag,1
		jz exit
gooleft:
		mov cx,5
		mov si,0
goleft:
		sub BlockBufC[si],6	;4>>>>>>>>>>>>
		add si,2
		loop goleft
		jmp exit
mide3:
		jmp exit
nleft:
		cmp ah,4dh	;right->
		jnz nright
		mov index,0	;清越界标志
		mov leftflag,0
		mov bottom,0
		call OutLine?
		cmp index,2
		jz exit
		call ifhere
		cmp rightflag,1
		jz exit
gooright:
		mov cx,5
		mov si,0
goright:	
		add BlockBufC[si],6		;4>>>>>>>>>>>>>>
		add si,2
		loop goright
		jmp exit
nright:
		cmp ah,50h	;down
		jnz ndown
		call ifhere
		cmp bottom,1
		jz exit
		call OutLine?
		cmp bottom,1
		jz exit
goodown:
		mov cx,5
		mov si,0
godown:
		add BlockBufR[si],6	;4>>>>>>>>>>>>>>>
		add si,2
		loop godown
ndown:	
exit:	
		mov oflag,0
		mov leftflag,0
		mov rightflag,0
		mov bottom,0
		mov ah,0ch	;清空键盘缓冲区	
		mov al,02h
		int 21h
		pop si
		pop dx
		pop cx
		pop bx
		pop ax
		ret
ChangeShape  	endp
OutShape?	proc near	;判断是否变形越界
		push ax
		push cx
		push si
		mov cx,4
		mov si,2
o13:
		mov ax,BlockBufR[si]
		cmp ax,50		;判断是否左越界
		jbe uout
		add si,2
		loop o13
		jmp left?
uout:
		mov oflag,1
		jmp exit3
left?:
		mov cx,4
		mov si,2
ooo4:	
		mov ax,BlockBufC[si]
		cmp ax,50		;判断是否左越界
		jbe lout
		add si,2
		loop ooo4
		jmp righ?
lout:
		mov oflag,1
		jmp exit3
righ?:
		mov cx,4
		mov si,2
ooo5:
		mov ax,BlockBufC[si]
		add ax,3
		cmp ax,113	;102	;判断是否右越界
		jae rout
		add si,2
		loop ooo5
		jmp dow?
rout:
		mov oflag,1
		jmp exit3
dow?:	
		mov cx,4
		mov si,2
ooo6:
		mov ax,BlockBufR[si]
		add ax,3
		cmp ax,175	;	140	;判断是否下越界
		jae dout
		add si,2
		loop ooo6
		jmp exit3
dout:	
		mov oflag,1
exit3:
		pop si
		pop cx
		pop ax
		ret
OutShape?	endp
DrawBlock	proc	near	;画初始方块
		push ax
		push cx
		push di
		push si
		mov cx,4
		mov si,2
o1o:
		push cx
		dec BlockBufC[si]
		sub BlockBufR[si],2
		mov cx,3
o7:
		push cx
		mov ah,0ch
		mov dx,BlockBufR[si]
		mov cx,BlockBufC[si]
		int 10h
		cmp flag1,0
		jnz nf0
		inc BlockBufC[si]
		pop cx
		loop o7
		mov cx,3	
		inc BlockBufR[si]
		inc flag1
		jmp o7
nf0:	
		cmp flag1,1
		jnz nf1
		inc BlockBufR[si]
		pop cx
		loop o7
		mov cx,3
		dec BlockBufC[si]
		inc flag1
		jmp o7
nf1:
		cmp flag1,2
		jnz nf2
		dec BlockBufC[si]
		pop cx
		loop o7
		mov cx,3
		dec BlockBufR[si]
		inc flag1
		jmp o7
mide:	
		jmp o1o
nf2:	
		dec BlockBufR[si]
		pop cx
		loop o7	
		add BlockBufC[si],2
		add BlockBufR[si],2
		add si,2		;>>>>>>>弱智啊,双层循环用的都是CX,用错了!冲突吧!!!!
		pop cx
		mov flag1,0	;又忘了清标志!!!
		loop mide
		pop si
		pop di
		pop cx
		pop ax
		ret
DrawBlock	endp
DrawPreview	proc	near	;画预览区方块
		push ax
		push cx
		push di
		push si
		mov cx,5
		mov si,0
ooooo6:
		add BlockBuf3r[si],17
		add BlockBuf3c[si],60
		add si,2
		loop  ooooo6
		mov cx,4
		mov si,2
oo1o:
		push cx
		dec BlockBuf3C[si]
		sub BlockBuf3R[si],2
		mov cx,3
d7oo:
		push cx	
		mov ah,0ch
		mov dx,BlockBuf3R[si]
		mov cx,BlockBuf3C[si]
		int 10h
		cmp flag1,0
		jnz nf00
		inc BlockBuf3C[si]
		pop cx	
		loop d7oo
		mov cx,3
		inc BlockBuf3R[si]
		inc flag1
		jmp d7oo
nf00:
		cmp flag1,1
		jnz nf11
		inc BlockBuf3R[si]
		pop cx
		loop d7oo
		mov cx,3
		dec BlockBuf3C[si]
		inc flag1
		jmp d7oo
nf11:
		cmp flag1,2
		jnz nf22
		dec BlockBuf3C[si]
		pop cx
		loop d7oo
		mov cx,3
		dec BlockBuf3R[si]
		inc flag1
		jmp d7oo
mmide:
		jmp oo1o
nf22:
		dec BlockBuf3R[si]
		pop cx
		loop d7oo
		add BlockBuf3C[si],2
		add BlockBuf3R[si],2
		add si,2		;>>>>>>>弱智啊,双层循环用的都是CX,用错了!冲突吧!!!!
		pop cx
		mov flag1,0	;又忘了清标志!!!
		loop mmide
		mov cx,5
		mov si,0
ooooo7:
		sub BlockBuf3r[si],17
		sub BlockBuf3c[si],60
		add si,2
		loop  ooooo7
		pop si
		pop	di
		pop cx
		pop ax
		ret
DrawPreview	endp
DropBlock    proc	near
		push cx
		push si
		call ifhere
		cmp bottom,1
		jz exit2
		call OutLine?
		cmp bottom,1
		jz exit2
godrop:
		mov si,0
		mov cx,5
o4:	
		add BlockBufR[si],6		;4>>>>>>>>>>>>>>>>>>>
		add si,2
		loop o4
		mov leftflag,0
		mov rightflag,0
exit2:	
		pop si
		pop cx
		ret
DropBlock	endp
delay	proc near		;延迟程序
		push cx
		push si
		mov si,150h
		mov cx,0
circ:
		loop $
		dec si
		jnz circ
		pop si
		pop cx	
		ret
delay endp
MovBuff 	proc near
		push ax
		push bx
		push cx
		push di
		push si
		mov bx,2
		mov cx,4
		mov si,BlockXR
		mov di,BlockXC
o5:
		mov ax,[si]
		mov BlockBufR[bx],ax
		mov ax,[di]
		mov BlockBufC[bx],ax
		add bx,2
		add si,2
		add di,2
		loop o5
		pop si
		pop di
		pop cx
		pop bx
		pop ax 
		ret
MovBuff	endp
getRam	proc	near		;初始产生随机方块
		push ax
		push bx
		push cx
		push dx
		push di
		push si
		mov ah,0
		int 1ah
		mov ax,dx
		and ah,0
		mov dl,7
		div dl
		mov SnakeType,ah
		cmp SnakeType,0
		jnz n0
		mov word ptr BlockBufR,56
		mov word ptr BlockBufC,74
		mov si,offset Block0r
		mov di,offset Block0c
		mov BlockXR,si
		mov BlockXC,di
		jmp n6
n0:
		cmp SnakeType,1
		jnz n1
		mov word ptr BlockBufR,56
		mov word ptr BlockBufC,80
		mov si,offset Block1r
		mov di,offset Block1c
		mov BlockXR,si
		mov BlockXC,di
		jmp n6
n1:
		cmp SnakeType,2
		jnz n2
		mov word ptr BlockBufR,62
		mov word ptr BlockBufC,80
		mov si,offset Block2r
		mov di,offset Block2c
		mov BlockXR,si
		mov BlockXC,di
		jmp n6
n2:
		cmp SnakeType,3
		jnz n3
		mov word ptr BlockBufR,62	;59
		mov word ptr BlockBufC,80	;75
		mov si,offset Block3r		
		mov di,offset Block3c
		mov BlockXR,si
		mov BlockXC,di
		jmp n6
n3:	
		cmp SnakeType,4
		jnz n4
		mov word ptr BlockBufR,62
		mov word ptr BlockBufC,80
		mov si,offset Block4r
		mov di,offset Block4c
		mov BlockXR,si
		mov BlockXC,di
		jmp n6
n4:	
		cmp SnakeType,5
		jnz n5
		mov word ptr BlockBufR,62
		mov word ptr BlockBufC,80
		mov si,offset Block5r
		mov di,offset Block5c
		mov BlockXR,si
		mov BlockXC,di
		jmp n6
n5:	
		mov word ptr BlockBufR,62
		mov word ptr BlockBufC,80
			mov si,offset Block6r
		mov di,offset Block6c
		mov BlockXR,si
		mov BlockXC,di	
n6:	
		pop si
		pop di
		pop dx
		pop cx
		pop bx
		pop ax
		ret
getRam 	endp
dFrame proc near		;画主窗体
		push cx
		push dx
		push bx
oo1:
		mov cx,dx
		push cx
		mov cx,bx
		push cx
		mov cx,dx
		push cx
		mov cx,bx
		push cx
		mov cx,dx
		push cx
		mov cx,bx
o1:
		push cx
	  	mov dx,dot1r
	  	mov cx,dot1c
	  	mov ah,0ch
	  	int 10h
	  	cmp fdot,0
	  	jnz nfdot0
	  	inc dot1c
	  	pop cx
	  	loop o1
	  	mov fdot,1
	  	pop cx
	  	jmp o1
mid:
		jmp oo1
nfdot0:
		cmp fdot,1
		jnz nfdot1
		inc dot1r
		pop cx
		loop o1
		mov fdot,2
		pop cx
		jmp o1
nfdot1:
		cmp fdot,2
		jnz nfdot2
		dec	 dot1c
		pop cx
		loop o1
		mov fdot,3
		pop cx
		jmp o1
nfdot2:
		dec dot1r
		pop cx
		loop  o1
		pop bx
		pop dx
		add bx,2
		add dx,2
		dec dot1c
		dec dot1r
		mov fdot,0
		dec times
		jnz mid
		pop bx
		pop dx
		pop cx
		ret
dFrame endp
CODES ENDS
    END START
;1532 LINES CODES
打赏