📄
字号:
TITLE GRID
;*********************************************************************
OBJECT STRUCT
shape db 0
status db 0
rectx dw 0
recty dw 0
OBJECT ENDS
;------------------------------------------------------------------------
;************************************************************************
DATA segment
key_left equ 4bh
key_right equ 4dh
key_down equ 50h
key_up equ 48h
CURRENT OBJECT <>
DOWNN_OK db 1
LR_OK db 1
NEXT_OK db 1
POINT_OK db 1
FALL_OK db 1
ONE_LINE_OK db 1
ANOTHER_OK db 1
POINTS DB 200 DUP(1)
PROMOTE DB 'SCORE: ','$'
PROMOTE2 DB 'GAMEOVER','$'
PTOMOTE3 DB 'PRESS ANY KEY TO EXIT','$'
score1 db 0
score2 db 0
score3 db 0
DATA ends
;------------------------------------------------------------------------
;************************************************************************
pro_nam segment
assume cs:pro_nam,ds:data
main proc far
start:
mov ax,data
mov ds,ax
mov ah,0 ;
mov al,4
int 10h
mov si,offset POINTS ;DISPLAY FRAME
call draw_frame
mov ah,02
mov bh,0
mov dh,7
mov dl,18
int 10h
mov ah,09 ;DISPLAY SCORE
mov dx,offset promote
int 21h
mov ah,02
mov bh,0
mov dh,9
mov dl,19
int 10h
mov ah,02
mov dl,'0'
int 21h
mov ah,02
mov dl,'0'
int 21h
mov ah,02
mov dl,'0'
int 21h
mov ah,0
int 16h
mov current.rectX,81 ;INITE CURRENT OBJECT
mov current.rectY,40
mov current.shape,2
mov current.status,1
game_begine:
call key_check
call FALL
call delay
call delay
cmp FALL_OK,0
jne game_begine
call FALL_STOP
call ANOTHER_OBJECT
cmp another_ok,1
jne end_game
jmp game_begine
end_game:
mov ah,02
mov bh,0
mov dh,12
mov dl,8
int 10h
mov ah,09 ;DISPLAY SCORE
mov dx,offset promote2
int 21h
mov ah,0h
int 16h
mov ah,4ch
int 21h
main endp
;--------------------------------------------------------------------------------------------------------------------------------
;********************************************* TOP PROC ****************************************************************
;-------------------------------------------------------------------
;*******************************************************************
ANOTHER_OBJECT PROC
mov another_ok,1
mov al,current.shape
shr al,1
jc ANOTHER_TO_SHAPE2
mov current.shape,1
jmp end_of_another
ANOTHER_TO_SHAPE2:
mov current.shape,2
END_OF_ANOTHER:
mov current.rectX,81 ;check whether the end of the game
mov current.rectY,40
mov ax,81
mov bx,47
call POINT_CHECK
CMP POINT_OK,0
jne ending
call draw_current
mov another_ok,0
ending:
ret
ANOTHER_OBJECT ENDP
;-------------------------------------------------------------------
;*******************************************************************
FALL PROC
call BOTTOM_CHECK
cmp FALL_OK,0
je no_fall
call CLEAR_CURRENT
add current.rectY,7
call DRAW_CURRENT
no_fall:
ret
FALL ENDP
;-------------------------------------------------------------------
;*******************************************************************
FALL_TO_BOTTOM PROC
call CLEAR_CURRENT
FALL_TO_BOTTOM_L:
call BOTTOM_CHECK
cmp FALL_OK,0
je END_OF_FALL_TO_BOTTOM
add current.rectY,7
JMP FALL_TO_BOTTOM_L ;fall to bottom
END_OF_FALL_TO_BOTTOM:
call DRAW_CURRENT
ret
FALL_TO_BOTTOM ENDP
;-------------------------------------------------------------------
;*******************************************************************
DRAW_CURRENT PROC
push ax
mov al,current.shape
shr al,1
jc shape1
shr al,1
jc shape2
jmp draw_exit
shape1: call DRAW_LONG
jmp draw_exit
shape2: call DRAW_DIAMOND
draw_exit:
pop ax
ret
DRAW_CURRENT ENDP
;-------------------------------------------------------------------
;*******************************************************************
FALL_STOP PROC
push ax
push bx
push cx
mov cx,4
mov al,current.shape
shr al,1
jc fall_stop_shape1
jmp fall_stop_shape2
fall_stop_shape1:
mov al,current.status
shr al,1
jc fall_stop_shape1_status1
shr al,1
jc fall_stop_shape1_status2
jmp end_of_fall_stop
fall_stop_shape1_status1:
mov ax,current.rectX
mov bx,current.rectY
fall_stop_shape1_status1_l:
call POINT_SET
add ax,7
loop fall_stop_shape1_status1_l
jmp end_of_fall_stop
fall_stop_shape1_status2:
mov ax,current.rectX
mov bx,current.rectY
fall_stop_shape1_status2_l:
call POINT_SET
add bx,7
loop fall_stop_shape1_status2_l
jmp end_of_fall_stop
fall_stop_shape2:
mov ax,current.rectX
mov bx,current.rectY
call POINT_SET
add ax,7
call POINT_SET
add bx,7
call POINT_SET
sub ax,7
call POINT_SET
END_OF_FALL_STOP:
call LINE_CHECK
pop cx
pop bx
pop ax
ret
FALL_STOP ENDP
;-------------------------------------------------------------------
;*******************************************************************
CHANGE_STATUE PROC
push ax
push cx
push bx
mov al,current.shape
shr al,1
jc CHANGE_STATUS_SHAPE1
jmp end_of_change_status
CHANGE_STATUS_SHAPE1:
mov al,current.status
cmp al,1
je SHAPE1_TO_STATUS2
SHAPE1_TO_STATUS1:
mov cx,3
mov ax,current.rectX
mov bx,current.rectY
add ax,28
cmp ax,130
ja end_of_change_status
sub ax,28
SHAPE1_TO_STATUS1_L:
add ax,7
call POINT_CHECK
cmp POINT_OK,0
je end_of_change_status
loop SHAPE1_TO_STATUS1_L
mov current.status,1
jmp end_of_change_status
SHAPE1_TO_STATUS2:
mov cx,3
mov ax,current.rectX
mov bx,current.rectY
SHAPE1_TO_STATUS2_L:
add bx,7
call POINT_CHECK
cmp POINT_OK,0
je end_of_change_status
loop SHAPE1_TO_STATUS2_L
mov current.status,2
jmp end_of_change_status
end_of_change_status:
pop bx
pop cx
pop ax
ret
CHANGE_STATUE ENDP
;------------------------------------------------------------------------------------------------------------------------
;******************************************** CHECK PROC ***************************************************
KEY_CHECK PROC
push ax
push cx
mov cx,0fffh
key_check_begine:
mov ah,01h
int 16h
jnz checking
loop key_check_begine
jmp key_check_exit
checking:
mov ah,0h
int 16h
mov al,ah
cmp al,key_left
jne not_left
call LEFT_BOUND_CHECK
cmp LR_OK,0
je end_of_check
call clear_current
sub current.rectX,7
jmp end_of_check
not_left: cmp al,key_right
jne not_right
call RIGHT_BOUND_CHECK
cmp LR_OK,0
je end_of_check
call clear_current
add current.rectX,7
jmp end_of_check
not_right: cmp al,key_up
jne not_up
call clear_current
call change_statue
jmp end_of_check
not_up: cmp al,key_down
jne end_of_check
call fall_to_bottom
end_of_check:
call draw_current
key_check_exit:
mov ah,01h
int 16h
jz no_buffer
mov ah,0h
int 16h
jmp key_check_exit
no_buffer:
pop cx
pop ax
ret
KEY_CHECK ENDP
;-------------------------------------------------------------------
;*******************************************************************
LEFT_BOUND_CHECK PROC
push ax
push bx
push dx
push cx
mov LR_OK,1
cmp current.rectX,60
je lbounded
mov al,current.shape
L_shape1: shr al,1
jnc L_shape2
mov al,current.status
shr al,1
jc shape1_status1
mov ax,current.rectX
mov bx,current.rectY
sub ax,7
mov cx,4
shape1_status2:
call POINT_CHECK
cmp POINT_OK,0
je LBOUNDED
add bx,7
loop shape1_status2
shape1_status1:
mov ax,current.rectX
mov bx,current.rectY
sub ax,7
call POINT_CHECK
cmp POINT_OK,0
je LBOUNDED
jmp END_OF_LEFT_BOUND_CHECK
L_shape2: mov ax,current.rectX
sub ax,7
mov bx,current.rectY
call POINT_CHECK
cmp POINT_OK,0
je LBOUNDED
add bx,7
call POINT_CHECK
cmp POINT_OK,0
je LBOUNDED
jmp end_of_left_bound_check
LBOUNDED: mov LR_OK,0
END_OF_LEFT_BOUND_CHECK:
pop cx
pop dx
pop bx
pop ax
ret
lEFT_BOUND_CHECK ENDP
;-------------------------------------------------------------------
;*******************************************************************
RIGHT_BOUND_CHECK PROC
push ax
push bx
push dx
push cx
mov LR_OK,1
mov al,current.shape
R_shape1: shr al,1
jnc R_shape2
mov al,current.status
shr al,1
jc R_SHAPE1_STATUS1
R_SHAPE1_STATUS2:
mov ax,current.rectX
cmp ax,123
je RBOUNDED
mov cx,4
add ax,7
mov bx,current.rectY
R_SHAPE1_STATUS2_L:
call POINT_CHECK
cmp POINT_OK,0
je RBOUNDED
add bx,7
loop R_SHAPE1_STATUS2_L
jmp end_of_right_bound_check
R_SHAPE1_STATUS1:
mov ax,current.rectX
add ax,28
cmp ax,130
je RBOUNDED
mov bx,current.rectY
call POINT_CHECK
cmp POINT_OK,0
je RBOUNDED
jmp END_OF_RIGHT_BOUND_CHECK
R_shape2: mov ax,current.rectX
mov bx,current.rectY
cmp ax,116
je RBOUNDED
add ax,14
call POINT_CHECK
cmp POINT_OK,0
je RBOUNDED
add bx,7
call POINT_CHECK
cmp POINT_OK,0
je RBOUNDED
jmp end_of_right_bound_check
;cmp now.rectY,130
RBOUNDED: mov LR_OK,0
END_OF_RIGHT_BOUND_CHECK:
pop cx
pop dx
pop bx
pop ax
ret
RIGHT_BOUND_CHECK ENDP
;--------------------------------------------------------------------
;********************************************************************
BOTTOM_CHECK PROC
push ax
push bx
push cx
mov FALL_OK,1
mov al,current.shape
shr al,1
jc bottom_check_shape1
shr al,1
jc bottom_check_shape2
jmp end_of_bottom_check
bottom_check_shape1:
mov al,current.status
shr al,1
jc bottom_check_shape1_status1
shr al,1
jc bottom_check_shape1_status2
jmp end_of_bottom_check
bottom_check_shape1_status1:
mov bx,current.rectY
cmp bx,173
je stop_falling
mov ax,current.rectX
mov cx,4
add bx,7
bottom_check_shape1_L1:
call POINT_CHECK
cmp POINT_OK,0
je stop_falling
add ax,7
loop bottom_check_shape1_L1
jmp end_of_bottom_check
bottom_check_shape1_status2:
mov ax,current.rectX
mov bx,current.rectY
cmp bx,173
je stop_falling
add bx,7*4
call POINT_CHECK
cmp POINT_OK,0
je stop_falling
jmp end_of_bottom_check
BOTTOM_CHECK_SHAPE2:
mov ax,current.rectX
mov bx,current.rectY
add bx,14
cmp bx,180
je stop_falling
call POINT_CHECK
cmp POINT_OK,0
je stop_falling
add ax,7
call POINT_CHECK
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -