.model small
;----------------------------------------------------------------------
;数据段
.data
;
x db 0
y db 0
;
win_time equ 5
chess_state dw ?
chess_x db ?
chess_y db ?
help_x db ?
help_y db ?
nothing1 db ?
nothing2 db ?
nothing3 db ?
chess_t db ?
person1 db ?
person2 db ?
person db ?
person_first db ?
jud db ?
;
person1_x equ 6
person1_y equ 3
person1_x1 equ 0
person1_y1 equ 0
person1_x2 equ 49
person1_y2 equ 14
;
person2_x equ 6
person2_y equ 68
person2_x1 equ 0
person2_y1 equ 64
person2_x2 equ 49
person2_y2 equ 79
;
map_x equ 6
map_y equ 20
map_x_end equ 44
map_y_end equ 58
map_x1 equ 6
map_y1 equ 15
map_x2 equ 44
map_y2 equ 63
;
answer_x equ 2
answer_y equ 28
answer_x1 equ 0
answer_y1 equ 15
answer_x2 equ 5
answer_y2 equ 63
;
end_x equ 47
end_y equ 26
end_x1 equ 45
end_y1 equ 15
end_x2 equ 49
end_y2 equ 63
;
map_size equ 19
map_over db ?
map db 400 dup(0)
;
string_doing db ' Want To Peace ! ','$'
string_person1 db ' P 1 : ','$'
string_person2 db ' P 2 : ','$'
string_p1 db ' Person 1 first . ','$'
string_p2 db ' Person 2 first . ','$'
string_win1 db ' Person 1 win. ','$'
string_win2 db ' Person 2 win. ','$'
string_peace db ' PEACE !!! ','$'
string_wrong db ' You can`t put here.','$'
string_end db ' I Want To End The Game ! ','$'
string_lose1 db ' P1 want to lose? ','$'
string_lose2 db ' P2 want to lose? ','$'
string_final1 db ' P1 win the final ! ','$'
string_final2 db ' P2 win the final ! ','$'
string_thank db ' Thank You Very Much !','$'
;
heart db 0,1,1,0,0,0,1,1,0
db 1,0,0,1,0,1,0,0,1
db 1,0,0,0,1,0,0,0,1
db 0,1,0,0,0,0,0,1,0
db 0,0,1,0,0,0,1,0,0
db 0,0,0,1,0,1,0,0,0
db 0,0,0,0,1,0,0,0,0
heart_size1 db 7
heart_size2 db 9
;
;----------------------------------------------------------------------
;清屏程序,gao_color为颜色,x1,y1,x2,y2为坐标
gao_clear_screen macro gao_color,x1,y1,x2,y2
push ax
push bx
push cx
push dx
;
mov ah,6
mov al,0
mov bh,gao_color
mov ch,x1
mov cl,y1
mov dh,x2
mov dl,y2
int 10h
;
pop dx
pop cx
pop bx
pop ax
endm
;----------------------------------------------------------------------
;画出当前状态
;辅助函数 1 , 判断x,y坐标在那个区域
gao_judge macro jud,x,y,x1,y1,x2,y2
local gao_judge_exit
;
mov jud,0
cmp x,x1
jl gao_judge_exit
cmp x,x2
jg gao_judge_exit
cmp y,y1
jl gao_judge_exit
cmp y,y2
jg gao_judge_exit
;
mov jud,1
;
gao_judge_exit:
;
endm
;辅助函数 2 , 输出相应语句的位置
gao_print_string macro string,x,y,gao_color
push ax
push bx
push cx
push dx
;
mov dh,x
mov dl,y
mov bx,offset string
mov al,[bx]
.while al!='$'
;
push bx
;
mov bh,0
mov ah,2
int 10h
;
mov bl,gao_color
mov bh,0
mov cx,1
mov ah,9
int 10h
;
pop bx
inc bx
inc dl
mov al,[bx]
.endw
;
pop dx
pop cx
pop bx
pop ax
endm
;辅助函数 3 - 1 , 打印当前棋盘一奇数行
gao_print_map_line1 macro x,y,gao_color
local gao_print_map_line1_repeat
push ax
push bx
push cx
push dx
;
mov dh,x
mov dl,y
mov bh,0
mov ah,2
int 10h
;
mov bh,0
mov ah,9
mov al,2bh
mov bl,gao_color
mov cx,1
int 10h
inc dl
mov cl,map_size
mov ch,0
;
gao_print_map_line1_repeat:
push cx
mov bh,0
mov ah,2
int 10h
;
mov al,2dh
mov bh,0
mov ah,9
mov cx,1
mov bl,gao_color
int 10h
inc dl
;
mov bh,0
mov ah,2
int 10h
;
mov al,2bh
mov bh,0
mov ah,9
mov bl,gao_color
int 10h
inc dl
pop cx
;
loop gao_print_map_line1_repeat
;
pop dx
pop cx
pop bx
pop ax
endm
;辅助函数 3 - 2 , 打印当前棋盘一偶数行
gao_print_map_line2 macro p,x,y,gao_color
local gao_print_map_line2_repeat
;
push ax
push bx
push cx
push dx
push ax
;
mov dh,x
mov dl,y
mov ah,2
mov bh,0
int 10h
;
mov ah,9
mov al,7ch
mov bh,0h
mov bl,gao_color
mov cx,1
int 10h
;
pop ax
mov ah,0
mov bx,map_size
push dx
mul bx
pop dx
mov cx,map_size
;
gao_print_map_line2_repeat:
push cx
inc dl
mov bx,offset map
add bx,ax
;
push ax
push bx
mov ah,2
mov bh,0
int 10h
;
pop bx
mov bl,[bx]
.if bl==0
mov al,20h
.elseif bl==1
mov al,1h
.else
mov al,2h
.endif
;
mov ah,9
mov bh,0
mov bl,gao_color
mov cx,1
int 10h
;
inc dl
mov ah,2
mov bh,0
int 10h
;
mov ah,9
mov al,7ch
mov bh,0
mov bl,gao_color
mov cx,1
int 10h
;
pop ax
inc ax
pop cx
loop gao_print_map_line2_repeat
;
pop dx
pop cx
pop bx
pop ax
endm
;辅助函数 3 , 打印当前棋盘状态
gao_print_map macro gao_color,x,y
push ax
push bx
push cx
push dx
;
gao_print_map_line1 x,y,gao_color
mov al,0h
.while al!=map_size
mov bl,al
add bl,al
add bl,x
add bl,1
gao_print_map_line2 al,bl,y,gao_color
add bl,1
gao_print_map_line1 bl,y,gao_color
inc al
.endw
;
pop dx
pop cx
pop bx
pop ax
endm
;辅助函数 4 - 1 , 将现在字符改变底色
gao_print_map_point_change macro x,y,gao_color
push ax
push bx
push cx
push dx
;
mov dh,x
mov dl,y
;
mov bh,0
mov ah,2
int 10h
;
mov bh,0
mov ah,8h
int 10h
;
mov bh,0
mov bl,gao_color
mov ah,9
mov cx,1
int 10h
;
pop dx
pop cx
pop bx
pop ax
endm
;辅助函数 4 , 如果当前操作的是棋盘 , 将棋盘相应位置的颜色变化为 0e7H 方式
gao_print_map_point macro x,y,gao_color
push ax
push bx
push cx
push dx
;
mov dh,x
mov dl,y
;
dec dh
dec dl
gao_print_map_point_change dh,dl,gao_color
;
inc dl
gao_print_map_point_change dh,dl,gao_color
;
inc dl
gao_print_map_point_change dh,dl,gao_color
;
inc dh
mov dl,y
dec dl
gao_print_map_point_change dh,dl,gao_color
;
inc dl
gao_print_map_point_change dh,dl,gao_color
;
inc dl
gao_print_map_point_change dh,dl,gao_color
;
inc dh
mov dl,y
dec dl
gao_print_map_point_change dh,dl,gao_color
;
inc dl
gao_print_map_point_change dh,dl,gao_color
;
inc dl
gao_print_map_point_change dh,dl,gao_color
;
pop dx
pop cx
pop bx
pop ax
endm
;打印当前比分
gao_printf_num macro x,y,gao_color,num
push ax
push bx
push cx
push dx
;
mov dh,x
mov dl,y
add dl,7
mov bh,0
mov ah,2
int 10h
mov al,num
;
add al,30h
mov ah,9h
mov bl,gao_color
mov cx,1
int 10h
;
pop dx
pop cx
pop bx
pop ax
endm
;辅助函数都不知道多少号了
gao_print_heart macro x,y,gao_color,num,word
push ax
push bx
push cx
push dx
;
mov dh,x
mov dl,y
inc dh
inc dh
mov bh,0
mov ah,2
int 10h
;
mov bl,num
mov ch,0
mov cl,0
;
.while bl>0
dec bl
push bx
.while ch<heart_size1
.while cl<heart_size2
push ax
push cx
mov bh,0
mov ah,2
int 10h
mov al,ch
mov ah,0
mov bl,heart_size2
mul bl
mov ch,0
add ax,cx
mov bx,offset heart
add bx,ax
mov bl,[bx]
.if bl==1
mov al,word
.else
mov al,20h
.endif
mov ah,9h
mov bl,gao_color
mov bh,0
mov cx,1
int 10h
pop cx
pop ax
inc cl
inc dl
.endw
inc dh
mov dl,y
inc ch
mov cl,0
.endw
inc dh
mov dl,y
mov ch,0
mov cl,0
pop bx
.endw
;
pop dx
pop cx
pop bx
pop ax
endm
;打印函数
gao_print macro
push ax
push bx
push cx
push dx
;
gao_judge [jud],[x],[y],person1_x1,person1_y1,person1_x2,person1_y2
.if [jud]==1
gao_c