VC驿站

 找回密码
 加入驿站

QQ登录

只需一步,快速开始

搜索
查看: 481|回复: 1

[交流] 推箱子

[复制链接]
36_avatar_middle
最佳答案
0 
在线会员 发表于 2019-6-21 12:59:55 | 显示全部楼层 |阅读模式
本帖最后由 王者归来339 于 2019-6-21 14:20 编辑

汇编写的推箱子,发上来交流学习

DATA    SEGMENT
SCORE DB 5 DUP('0'),'$'
PADMSG DB 44 DUP(219)
ENDMSG  DB 0DH,0AH,'GOOD BYE!',0DH,0AH,'$'
crmsg db 13,10,'$'

SG3 DB 'Do you want to play again?(Yes/No)'

circle DB 00H,00H,07H,0C0H,1FH,0F0H,3FH,0F8H,3FH,0F8H,7FH,0FCH,7FH,0FCH,7FH,0FCH
        DB 7FH,0FCH,7FH,0FCH,3FH,0F8H,3FH,0F8H,1FH,0F8H,07H,0C0H,00H,00H,00H,00H
row db 10
col db 26
initrow db 10
initcol db 24
mrow db 1
mcol db 3
rflag dw 0
cflag dw 0
aimmsg DB 3 DUP(?,?,?)
SCOREMSG1       DB      201,11 DUP(205),187
SCOREMSG2       DB      186,'SCORE:     ',186
SCOREMSG3       DB      204,11 DUP(205),185
SCOREMSG4       DB      186,'LEFT  : A  ',186
SCOREMSG5       DB      186,'RIGHT : D  ',186
SCOREMSG6       DB      186,'UP    : W  ',186
SCOREMSG7       DB      186,'DOWN  : S  ',186
SCOREMSG8       DB      186,'-----------',186
SCOREMSG9       DB      186,'EXIT  : ESC',186
SCOREMSG10      DB      200,11 DUP(205),188
num dw ?
num1 dw ?
num2 dw ?
num3 dw ?
SG DB 'http://bbs.bccn.net/'
FORM DB 2,2,2,2,2,2,2,2,2
      DB 2,2,0,0,0,0,0,2,2
      DB 2,2,0,0,0,2,2,2,2
      DB 2,2,2,0,0,0,0,0,2
      DB 2,0,0,0,2,0,2,0,2
      DB 2,0,0,0,2,0,0,0,2
      DB 2,0,0,0,2,2,2,2,2
      DB 2,2,2,2,2,2,2,2,2
DATA ENDS




stack segment stack
db 200 dup(?)
stack ends

code segment
assume cs:code,ds:data,es:data,ss:stack
start:
mov ax,data
mov ds,ax
push ds

gameover:
mov ah,00h
mov al,12h
int 10h
mov ah,0bh
mov bh,01
mov bl,00h
int 10h

call initgame
call aim
call man
call dispscore

keyboard:
mov ah,0
int 16h
push ax
mov ah,1
int 16h
jz keyboard2
pop ax
jmp keyboard

keyboard2:
pop ax
cmp al,1bh
jz sexit1
cmp al,'a'
jz temleft1
cmp al,'s'
jz temdown1
cmp al,'d'
jz temright1
cmp al,'w'
jz up
jmp keyboard

up:
call up1
mov si,offset aimmsg
mov al,0h
cmp byte ptr [si+2],3
jz addnum1
jmp nflag1

addnum1:
add al,1
jmp nflag1

nflag1:
add si,3
cmp byte ptr [si+2],3
jz addnum2
jmp temflag1

sexit1:
jmp sexit2

temleft1:
jmp left

temdown1:
jmp down

temright1:
jmp right

temflag1:
jmp nflag2

addnum2:
add al,1
jmp nflag2

nflag2:
add si,3
jmp tempflag2

tgameover1:
mov initrow,10
mov initcol,24
mov mrow,1
mov mcol,3
jmp gameover

tempflag2:
cmp byte ptr [si+2],3
jz addnum3
jmp nflag3

addnum3:
add al,1
jmp nflag3

nflag3:
add al,'0'
mov score[4],al
push ax
call dispscore
pop ax
sub al,'0'

cmp al,3
jz oflag1

jmp hflag1

oflag1:
mov ah,0
int 16h
cmp al,1bh
jz eexit
jmp oflag1

eexit:
mov ax,0003h
int 10h
MOV BP,OFFSET SG3
MOV     CX,34
MOV     DX,0H
MOV BH,0H
MOV AL,0H
MOV BL,00001111B
MOV AH,13H
INT 10H
MOV  AH,0
INT  16H
cmp al,'y'
jz tgameover1
cmp al,'Y'
jz tgameover1
jmp exit

sexit2:
jmp exit

hflag1:
jmp keyboard

down:
call down1
jmp keyboard

left:
call left1
jmp keyboard

right:
call right1
mov si,offset aimmsg
mov al,0h
cmp byte ptr [si+2],3
jz adddnum1
jmp nfflag1

adddnum1:
add al,1
jmp nfflag1

nfflag1:
add si,3
cmp byte ptr [si+2],3
jz adddnum2
jmp nfflag2

adddnum2:
add al,1
jmp nfflag2

nfflag2:
add si,3
cmp byte ptr [si+2],3
jz adddnum3
jmp nfflag3

adddnum3:
add al,1
jmp nfflag3

nfflag3:
add al,'0'
mov score[4],al
jmp tempflag3

tgameover2:
jmp gameover

tempflag3:
push ax
call dispscore
pop ax
sub al,'0'

cmp al,3
jz oflag2

jmp hflag2

oflag2:
mov ah,0
int 16h
cmp al,1bh
jz eeexit
jmp oflag2

eeexit:
mov ax,0003h
int 10h
MOV BP,OFFSET SG3
MOV     CX,34
MOV     DX,0H
MOV BH,0H
MOV AL,0H
MOV BL,00001111B
MOV AH,13H
INT 10H
MOV  AH,0
INT  16H
cmp al,'y'
jz tgameover2

cmp al,'Y'
jz tgameover2

jmp exit

hflag2:
jmp keyboard

exit:
mov ax,0003h
int 10h
mov ax,4c00h
int 21h

down1 proc near
mov si,offset form
mov al,initrow
sub al,8
mov bl,9
mul bl
add si,ax

mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1

cmp byte ptr [si],3
jnz dno3
jmp dbcircle

dno3:
cmp byte ptr[si],4
jnz dflag1
jmp dacircle

dflag1:
cmp byte ptr [si],2
jnz dflag2
jmp dwcircle

dflag2:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b

mov ax,1300h
int 10h
inc initrow
call man1

cmp initcol,26
jz dagcircle1
jmp ddirectflag1

dagcircle1:
cmp initrow,11
jz dagcircle2
jmp ddirectflag1

dagcircle2:
push ax
mov al,initcol
mov col,al
pop ax
mov si,offset circle
call show
jmp ddirectflag1

ddirectflag1:
mov rflag,1
mov si,offset form
mov al,initrow
sub al,9
mov bl,9
mul bl
add si,ax
mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1

cmp byte ptr [si],4
jnz dmodify1
jmp dfflag1

dmodify1:
mov byte ptr [si],1
cmp byte ptr [si-9],4
jnz dmodify2
jmp dfflag1

dmodify2:
mov byte ptr [si-9],0
jmp dfflag1

dfflag1:
mov si,offset form
mov al,initrow
sub al,8
mov bl,9
mul bl
add si,ax
mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1

jmp exit1

dbcircle:
mov si,offset form
mov al,initrow
sub al,7
mov bl,9
mul bl
add si,ax
mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1

cmp byte ptr [si],3
jnz dno33
jmp dbcircle1

dno33:
cmp byte ptr [si],4
jnz dflag3
jmp dacircle1

dflag3:
cmp byte ptr [si],2
jnz dflag4
jmp dwcircle1

dflag4:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
inc initrow

mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
call man1
mov si,offset form
mov al,initrow
sub al,9
mov bl,9
mul bl
add si,ax

mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1

cmp byte ptr [si],4
jnz dmodify3
jmp dfflag2

dmodify3:
mov byte ptr [si],1
jmp dfflag2

dfflag2:
mov dh,initrow
inc dh
mov dl,initcol
mov bh,00
mov bl,01010101b
call dispcell
cmp byte ptr [si+9],2
jnz modify1
jmp dfflag3

modify1:
mov byte ptr [si+9],3
cmp byte ptr [si-9],4
jnz dmodify4
jmp dfflag3

dmodify4:
mov byte ptr [si-9],0
jmp dfflag3

dfflag3:
jmp flag2

flag2:
mov rflag,1
jmp exit1

dbcircle1:
push ax
push bx
push cx
push dx
push di
push si
mov rflag,0
jmp exit1

dacircle1:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
inc initrow
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
call man1

mov dh,initrow
inc dh
mov dl,initcol
mov bh,0
mov bl,01011110b
call dispcell
mov rflag,1
jmp exit1

dwcircle1:
push ax
push bx
push cx
push dx
push di
push si
mov rflag,0
jmp exit1

dacircle:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
inc initrow
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h

call man1
mov rflag,1
jmp exit1

dwcircle:
push ax
push bx
push cx
push dx
push di
push si
mov rflag,0
jmp exit1

exit1:
cmp rflag,0
jnz dmmodify1
jmp dexit1

dmmodify1:
inc mrow
mov rflag,0
jmp dexit1

dexit1:
pop si
pop di
pop dx
pop cx
pop bx
pop ax

ret
down1 endp




up1 proc near
mov si,offset form
mov al,initrow
sub al,10
mov bl,9
mul bl
add si,ax
mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1

cmp byte ptr [si],3
jnz duno3
jmp ubcircle

duno3:
cmp byte ptr[si],4
jnz dflag5
jmp uacircle

dflag5:
cmp byte ptr [si],2
jnz dflag6
jmp uwcircle

dflag6:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
dec initrow
call man1
mov rflag,1
mov si,offset form
mov al,initrow
sub al,9
mov bl,9
mul bl
add si,ax
mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1

cmp byte ptr [si],4
jnz umodify1
jmp ufflag1

umodify1:
mov byte ptr [si],1
cmp byte ptr [si+9],4
jnz umodify2
jmp ufflag1

umodify2:
mov byte ptr [si+9],0
jmp ufflag1

ufflag1:
mov si,offset form
mov al,initrow
sub al,9
mov bl,9
mul bl
add si,ax
mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1

jmp exit2

ubcircle:
mov si,offset form
mov al,initrow
sub al,10
mov bl,9
mul bl
add si,ax
mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1

cmp byte ptr [si-9],3
jnz duno33
jmp ubcircle1

duno33:
cmp byte ptr [si-9],4
jnz dflag7
jmp uacircle1

dflag7:
cmp byte ptr [si-9],2
jnz dflag8
jmp uwcircle1

dflag8:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
dec initrow
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h

call man1
mov rflag,1
mov si,offset form
mov al,initrow
sub al,9
mov bl,9
mul bl
add si,ax
mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1

cmp byte ptr [si],4
jnz umodify3
jmp ufflag2

umodify3:
mov byte ptr [si],1
jmp ufflag2

ufflag2:
mov dh,initrow
dec dh
mov dl,initcol
mov bh,00
mov bl,01010101b
call dispcell
cmp byte ptr [si-9],2
jnz modify2
jmp ufflag3

modify2:
mov byte ptr [si-9],3
cmp byte ptr [si+9],4
jnz umodify4
jmp ufflag3

umodify4:
mov byte ptr [si+9],0
jmp ufflag3

ufflag3:
jmp flag3

flag3:
jmp exit2

ubcircle1:
push ax
push bx
push cx
push dx
push di
push si
mov rflag,0
jmp exit2

uacircle1:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
dec initrow
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h

call man1
mov si,offset form
mov al,initrow
sub al,9
mov bl,9
mul bl
add si,ax
mov al,mcol
inc al
mov ah,0h
add si,ax
sub si,1
mov byte ptr [si],1
mov byte ptr [si+9],0
mov rflag,1
mov dh,initrow
dec dh
mov dl,initcol
mov bh,0
mov bl,01011011b

call dispcell
mov si,offset aimmsg
mov byte ptr [si+2],3
jmp exit2

uwcircle1:
push ax
push bx
push cx
push dx
push di
push si
mov rflag,0
jmp exit2

uacircle:
push ax
push bx
push cx
push dx
push di
push si
mov si,offset aimmsg
cmp byte ptr [si+2],3
jz uaeexit1
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
dec initrow
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h

call man2
mov rflag,1

uaeexit1:
jmp exit2

uwcircle:
push ax
push bx
push cx
push dx
push di
push si
mov rflag,0
jmp exit2

exit2:
cmp rflag,0
jnz ummodify1
jmp uexit1

ummodify1:
dec mrow
mov rflag,0
jmp uexit1

uexit1:
pop si
pop di
pop dx
pop cx
pop bx
pop ax

ret
up1 endp





right1 proc near
mov si,offset form
mov al,initcol
shr al,1
sub al,7
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

cmp byte ptr [si],3
jnz rno3
jmp rbcircle

rno3:
cmp byte ptr[si],4
jnz dflag13
jmp racircle

dflag13:
cmp byte ptr [si],2
jnz dflag14
jmp rwcircle

dflag14:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
inc initcol
inc initcol
call man1

mov si,offset form
mov al,initcol
shr al,1
sub al,8
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1
cmp byte ptr [si],4
jnz rmodify1
jmp rfflag1

rmodify1:
mov byte ptr [si],1
cmp byte ptr [si-1],4
jnz rmodify2
jmp rfflag1

rmodify2:
mov byte ptr [si-1],0
jmp rfflag1

rfflag1:
mov si,offset form
mov al,initcol
shr al,1
sub al,7
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

mov cflag,1
jmp exit4

rbcircle:
mov si,offset form
mov al,initcol
shr al,1
sub al,7
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

cmp byte ptr [si+1],3
jnz rno33
jmp rbcircle1

rno33:
cmp byte ptr [si+1],4
jnz dflag15
jmp racircle1

dflag15:
cmp byte ptr [si+1],2
jnz dflag16
jmp rwcircle1

dflag16:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
inc initcol
inc initcol
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
call man1

mov si,offset form
mov al,initcol
shr al,1
sub al,7
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

sub si,1
mov byte ptr [si],1
mov dh,initrow
mov dl,initcol
inc dl
inc dl
mov bh,00
mov bl,01010101b
call dispcell
cmp byte ptr [si-1],2
jnz modify4
jmp rfflag2

modify4:
mov byte ptr [si-1],0
cmp byte ptr [si+1],4
jnz rmodify3
jmp rfflag2

rmodify3:
mov byte ptr [si+1],3
jmp rfflag2

rfflag2:
jmp flag5

flag5:

mov cflag,1
jmp exit4

rbcircle1:
push ax
push bx
push cx
push dx
push di
push si
mov cflag,0
jmp exit3

racircle1:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
inc initcol
inc initcol

mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
call man1

mov si,offset form
mov al,initcol
shr al,1
sub al,8
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

cmp byte ptr [si],4
jnz rmodify4
jmp rfflag3

rmodify4:
mov byte ptr [si],1
jmp rfflag3

rfflag3:
mov dh,initrow
mov dl,initcol
inc dl
inc dl
mov bh,0
mov bl,01011011b
call dispcell

cmp byte ptr [si-1],2
jnz rcmp1
jmp rfflag4

rcmp1:
cmp byte ptr [si-1],4
jnz rmodify5
jmp rfflag4

rmodify5:
mov byte ptr [si-1],0
cmp byte ptr [si+1],4
jnz rmodify6
jmp rfflag4

rmodify6:
mov byte ptr [si+1],3
jmp rfflag4

rfflag4:
mov cflag,1
mov si,offset aimmsg
mov byte ptr [si+2],3
jmp reexit1

reexit1:
jmp exit4

rwcircle1:
push ax
push bx
push cx
push dx
push di
push si
mov cflag,0
jmp exit4

racircle:
push ax
push bx
push cx
push dx
push di
push si
mov si,offset aimmsg
mov al,initcol
shr al,1
sub al,12
mov ah,0h
mov bl,3
mul bl
add si,ax

cmp byte ptr [si+2],3
jz rfffflag1
jmp raacircle1

rfffflag1:
mov al,initcol
shr al,1
sub al,12
cmp al,2
jb rfffffflag1
jmp reexit3

rfffffflag1:
add si,3
cmp byte ptr [si+2],3
jz rmtflag1
jmp rffflag2

rffflag2:
mov si,offset form
mov al,initcol
shr al,1
sub al,7
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

cmp byte ptr [si+1],2
jnz rfffflag2
jmp reexit3

rfffflag2:
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
jmp rfffffffffflag1

rmtflag1:
jmp rmtflag2

rfffffffffflag1:
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
inc dl
inc dl
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
inc initcol
inc initcol
call man2
cmp mcol,4
jnb ragcircle2
jmp rfffffffflag1

ragcircle2:
push ax
mov al,initcol
mov col,al
dec col
dec col
pop ax
mov si,offset circle
call show
jmp rfffffffflag1

rmtflag2:
jmp rmflag1

rfffffffflag1:
mov si,offset form
mov al,initcol
shr al,1
sub al,8
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
jmp rfffffflag2

rmflag1:
jmp reexit3

rfffffflag2:
sub si,1  
cmp byte ptr [si-1],4
jnz rmmodify2
jmp rffflag3

rmmodify2:
mov byte ptr [si-1],0
jmp rffflag3

rffflag3:
mov si,offset aimmsg
mov al,initcol
shr al,1
sub al,12
mov ah,0h
mov bl,3
mul bl
add si,ax
mov byte ptr [si+2],3
sub si,3
mov byte ptr [si+2],0

rffflag4:
mov dh,initrow
mov dl,initcol
inc dl
inc dl
mov bh,0
mov bl,01011011b
call dispcell
cmp initcol,26
jz rmmmodify3
jmp rffflag5

rmmmodify3:
mov si,offset form
mov al,initcol
dec al
dec al
shr al,1
sub al,8
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1  
mov byte ptr [si],0
jmp rffflag5

rffflag5:
jmp reexit2

raacircle1:
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
  mov ax,1300h
int 10h
inc initcol
inc initcol
call man2
mov si,offset form
mov al,initcol
shr al,1
sub al,8
mov ah,0h
add si,ax

mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1  
cmp byte ptr [si],4
jnz rmmmodify1
jmp rdirectflag1

rmmmodify1:
mov byte ptr [si],0
jmp printf1

printf1:
jmp rdirectflag1

rdirectflag1:
mov si,offset mcol
cmp mcol,4
jnb ragcircle1
jmp reexit2

ragcircle1:
push ax
mov al,initcol
mov col,al
dec col
dec col
pop ax
mov si,offset circle
call show
jmp reexit2

reexit2:
mov cflag,1
jmp reexit4

reexit3:
mov cflag,0
jmp reexit4

reexit4:
jmp exit4

rwcircle:
push ax
push bx
push cx
push dx
push di
push si
mov cflag,0
jmp exit4

exit4:
cmp cflag,0
jnz rmmodify3
jmp rexit1

rmmodify3:
inc mcol
jmp rexit1

rexit1:
mov si,offset mcol
pop si
pop di
pop dx
pop cx
pop bx
pop ax

ret
right1 endp







left1 proc near
mov si,offset form
mov al,initcol
shr al,1
sub al,9
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

cmp byte ptr [si],3
jnz lno3
jmp lbcircle

lno3:
cmp byte ptr[si],4
jnz dflag9
jmp lacircle

dflag9:
cmp byte ptr [si],2
jnz dflag10
jmp lwcircle

dflag10:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
dec initcol
dec initcol
call man1
cmp mcol,4
jz ljflag1

jmp lfffffflag1

ljflag1:
cmp initrow,10
jnz lfffffflag1
push ax
mov al,initcol
mov col,al
inc col
inc col
pop ax
mov si,offset circle
call show

lfffffflag1:
mov si,offset form
mov al,initcol
shr al,1
sub al,8
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

cmp byte ptr [si],4
jnz lmodify1
jmp lfflag1

lmodify1:
mov byte ptr [si],1
cmp byte ptr [si+1],4
jnz lmodify2
jmp lfflag1

lmodify2:
mov byte ptr [si+1],0
jmp lfflag1

lfflag1:
mov si,offset form
mov al,initcol
shr al,1
sub al,9
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

mov cflag,1
jmp exit3

lbcircle:
mov si,offset form
mov al,initcol
shr al,1
sub al,9
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

cmp byte ptr [si-1],3
jnz lno33
jmp lbcircle1

lno33:
cmp byte ptr [si-1],4
jnz dflag11
jmp lacircle1

dflag11:
cmp byte ptr [si-1],2
jnz dflag12
jmp lwcircle1

dflag12:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
dec initcol
dec initcol
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b

mov ax,1300h
int 10h
call man1
mov si,offset form
mov al,initcol
shr al,1
sub al,8
mov ah,0h
add si,ax
mov al,mrow
mov bl,9
mul bl
add si,ax
sub si,1

cmp byte ptr [si],4
jnz lmodify3
jmp lfflag2

lmodify3:
mov byte ptr [si],1
jmp lfflag2

lfflag2:
mov dh,initrow
mov dl,initcol
dec dl
dec dl
mov bh,00
mov bl,01010101b
call dispcell
cmp byte ptr [si-1],2
jnz modify3
jmp lfflag3

modify3:
mov byte ptr [si-1],3
cmp byte ptr [si+1],4
jnz lmodify4
jmp lfflag3

lmodify4:
mov byte ptr [si+1],0
jmp lfflag3

lfflag3:
jmp flag4

flag4:
mov cflag,1
jmp exit3

lbcircle1:
push ax
push bx
push cx
push dx
push di
push si
mov cflag,0
jmp exit3

lacircle1:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
dec initcol
dec initcol
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b

mov ax,1300h
int 10h
call man1
mov si,offset form
mov al,initcol
shr al,1
sub al,8
mov ah,0h
add si,ax
mov al,1
mov bl,9
mul bl
add si,ax
sub si,1

cmp byte ptr [si],4
jnz lmodify5
jmp lflag4

lmodify5:
mov byte ptr [si],1
jmp lflag4

lflag4:
mov dh,initrow
mov dl,initcol
dec dl
mov bh,0
mov bl,01011110b
call dispcell
cmp byte ptr [si-1],2
jnz lcmp1
jmp lfflag5

lcmp1:
cmp byte ptr [si-1],4
jnz lmodify6
jmp lfflag5

lmodify6:
mov byte ptr [si-1],3
cmp byte ptr [si+1],4
jnz lmodify7
jmp lfflag5

lmodify7:
mov byte ptr [si+1],0
jmp lfflag5

lfflag5:
mov cflag,1
jmp exit3

lwcircle1:
push ax
push bx
push cx
push dx
push di
push si
mov cflag,0
jmp exit3

lacircle:
push ax
push bx
push cx
push dx
push di
push si
mov bp,offset padmsg
mov cx,02
mov dh,initrow
mov dl,initcol
mov bh,00
mov al,0
mov bl,01010000b
mov ax,1300h
int 10h
dec initcol
dec initcol
call man2
cmp mcol,4
jnb lagcircle1
jmp lfffflag1

lagcircle1:
push ax
mov al,initcol
mov col,al
inc col
inc col
pop ax
mov si,offset circle
call show
jmp lfffflag1

lfffflag1:
mov cflag,1
jmp exit3

lwcircle:
push ax
push bx
push cx
push dx
push di
push si
mov cflag,0
jmp exit3

exit3:
cmp cflag,0
jnz lmmodify1
jmp lexit1

lmmodify1:
dec mcol
mov cflag,0
jmp lexit1

lexit1:
mov si,offset mcol
pop si
pop di
pop dx
pop cx
pop bx
pop ax

ret
left1 endp




DISPSCORE PROC NEAR
MOV AX,DATA
MOV ES,AX
MOV BP,OFFSET SCORE
MOV CX,05H
        MOV     DX,0643H
MOV BH,0H
MOV AL,0H
MOV BL,00110100B
MOV AH,13H
INT 10H
RET
DISPSCORE ENDP




CLS PROC NEAR
MOV CX,0
MOV DH,24
MOV DL,79
MOV BH,0
MOV AX,600H
INT 10H
RET
CLS ENDP





DISPPAD PROC NEAR   ;BX BH=PAGE BL=COLOR
MOV CX,NUM
MOV DH,12
MOV DL,24
CALL DISPCELL

mov dh,14
mov dl,22
call dispcell

mov dh,13
mov dl,28
call dispcell

RET
DISPPAD ENDP

DISPCELL PROC NEAR;DH=ROW DL=COL BH=PAGE BL=COLOR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH DI
PUSH SI
MOV BP,OFFSET PADMSG
MOV CX,02H
MOV AX,1300H
INT  10H
CMP BL,0H
JE SKIP20
;CALC ROW
MOV AH,0H
MOV AL,DH
        MOV     CL,16
MUL CL
MOV SI,AX
;CALC COL
MOV AH,0H
MOV AL,DL
MOV CL,8
MUL CL
MOV DI,AX
;DRAW
MOV AX,0C00H
MOV DX,SI
        ADD     DX,15
MOV CX,16
LOOP21: ADD CX,DI
DEC CX
INT 10H
INC CX
SUB CX,DI
LOOP LOOP21
jmp flag1

skip20:
jmp skip21

flag1:
        MOV     DX,SI
        MOV     CX,15
        ADD     DI,15
LOOP22: PUSH    CX
        MOV     CX,DI
        INT     10H
        INC     DX
        POP     CX
        LOOP    LOOP22

        SUB     DI,2
        DEC     DX
        MOV     CX,13
LOOP23: PUSH    CX
        DEC     DX
        MOV     CX,DI
        INT     10H
        SUB     CX,12
        MOV     AL,07H
        INT     10H
        MOV     AL,00H
        POP     CX
        LOOP    LOOP23

        MOV     AX,0C07H
MOV DX,SI
        ADD     DX,1
        MOV     CX,12
        SUB     DI,12
LOOP24: ADD     CX,DI
INT 10H
SUB CX,DI
        LOOP    LOOP24

mov ax,0c00h
mov dx,si
add dx,15
mov cx,8
loop25:
add cx,7
add cx,di
int 10h
dec dx
sub cx,di
sub cx,7
loop loop25

mov ax,0c07h
mov cx,7
loop26:
add cx,1
add cx,di
int 10h
dec dx
sub cx,di
sub cx,1
loop loop26

mov ax,0c00h
mov dx,si
mov cx,8
loop27:
add cx,7
add cx,di
int 10h
inc dx
sub cx,di
sub cx,7
loop loop27

mov ax,0c07h
mov cx,7
loop28:

add cx,di
int 10h
inc dx
sub cx,di

loop loop28

SKIP21: POP SI
POP DI
POP DX
POP CX
POP BX
POP AX
RET
DISPCELL ENDP







INITGAME PROC NEAR
CALL CLS
;DRAW   TEXTFRAME
MOV AX,DATA
MOV ES,AX
        MOV     CX,10
MOV BP,OFFSET SCOREMSG1
        MOV     DX,053CH
LOOP72: PUSH CX
        MOV     CX,13
MOV AL,0H
MOV BH,0H
        MOV     BL,01011010B
MOV AH,13H
INT 10H
        ADD     BP,13
INC DH
POP CX
LOOP LOOP72

;DRAW BOARDFRAME
MOV BP,OFFSET PADMSG
        MOV     CX,0044
        MOV     DX,0304H
MOV BH,0H
MOV AL,0H
MOV BL,00110100B
MOV AH,13H
INT 10H
        MOV     DX,1804H
INT 10H

mov dx,0404h
int 10h
mov dx,1704h
int 10h

mov dx,0504h
int 10h
mov dx,1604h
int 10h

mov dx,0604h
int 10h
mov dx,1504h
int 10h

mov dx,0704h
int 10h
mov dx,1404h
int 10h

mov dx,0804h
int 10h
mov dx,1304h
int 10h

mov dx,0904h
int 10h
mov dx,1204h
int 10h

mov dx,1004h
int 10h
mov dx,1104h
int 10h

MOV CX,6
        MOV     DX,0904H
LOOP4: MOV SI,CX
MOV CX,02
INC DH
INT 10H
MOV CX,SI
LOOP LOOP4

MOV CX,6
        MOV     DX,092EH
INITGAME1: MOV SI,CX
MOV CX,02
INC DH
INT 10H
MOV CX,SI
LOOP INITGAME1

mov cx,6
mov dx,0906h
loop5:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop loop5

mov cx,6
mov dx,092ch
initgame2:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop initgame2

mov cx,6
mov dx,0908h
loop6:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop loop6

mov cx,6
mov dx,092ah
initgame3:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop initgame3

mov cx,6
mov dx,090ah
loop7:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop loop7

mov cx,6
mov dx,0928h
initgame4:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop initgame4

mov cx,6
mov dx,090ch
loop8:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop loop8

mov cx,6
mov dx,0926h
initgame5:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop initgame5

mov cx,6
mov dx,090eh
loop9:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop loop9

mov cx,6
mov dx,0924h
initgame6:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop initgame6

mov cx,6
mov dx,0910h
loop10:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop loop10

mov cx,6
mov dx,0922h
initgame7:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop initgame7

mov cx,6
mov dx,0912h
loop111:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop loop111

mov cx,2
mov dx,0920h
initgame8:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop initgame8

mov dx,0e20h
inc dh
mov cx,2
int 10h

mov cx,3
mov dx,0914h
loop112:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop loop112

mov cx,1
mov dx,091eh
inc dh
initgame9:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop initgame9

mov dx,0c1eh
inc dh
mov cx,2
int 10h

mov dx,0e1eh
inc dh
mov cx,2
int 10h

mov cx,1
mov dx,0916h
loop113:
mov si,cx
mov cx,2
inc dh
inc dh
inc dh
int 10h
mov cx,si
loop loop113

mov cx,1
mov dx,091ch
inc dh
initgame10:
mov si,cx
mov cx,2
inc dh
int 10h
mov cx,si
loop initgame10

mov dx,0e1ch
inc dh
mov cx,2
int 10h

mov dx,0c1ah
inc dh
mov cx,2
int 10h

mov dx,0c1ah
inc dh
inc dh
mov cx,2
int 10h

mov dx,0c1ah
inc dh
inc dh
inc dh
mov cx,2
int 10h

;FORMAT SCORE
MOV DI,OFFSET SCORE
MOV AL,'0'
MOV CX,05H
REP STOSB

MOV NUM,3

MOV SI,OFFSET FORM
MOV CX,72
IN1:
MOV AL,[SI]
CMP AL,1
JNZ IN2
MOV BYTE PTR [SI],0
JMP IN4
IN2:
CMP AL,3
JNZ IN3
MOV BYTE PTR [SI],0
jmp in4
in3:
cmp al,4
jnz in4

mov byte ptr [si],0
jmp in4

IN4:
INC SI
LOOP IN1

MOV SI,OFFSET FORM
ADD SI,12

MOV BYTE PTR [SI],1

mov si,offset form
add si,30
mov byte ptr [si],3

mov si,offset form
add si,47
mov byte ptr [si],3

mov si,offset form
add si,41
mov byte ptr [si],3

mov si,offset form
add si,13
mov byte ptr [si],4

mov si,offset form
add si,14
mov byte ptr [si],4

mov si,offset form
add si,15
mov byte ptr [si],4

mov si,offset aimmsg
mov byte ptr [si],10
mov byte ptr [si+1],26
mov byte ptr [si+2],0

add si,3

mov byte ptr[si],10
mov byte ptr[si+1],28
mov byte ptr [si+2],0

add si,3

mov byte ptr [si],10
mov byte ptr [si+1],30
mov byte ptr [si+2],0

mov num3,0
MOV BL,01010101B
call disppad

RET
INITGAME ENDP




man2 proc near
mov ax,data
mov es,ax

mov dh,initrow
mov cl,16
mov al,dh
mul cl
mov si,ax

mov ch,initcol
mov cl,8
mov al,ch
mul cl
mov di,ax

mov ax,0c0bh
mov dx,si
add dx,15
mov cx,16
loop321:
add cx,di
int 10h
sub cx,di
loop loop321

mov dx,si
mov cx,16
add di,15
loop322:
push cx
mov cx,di
int 10h
inc dx
pop cx
loop loop322

sub di,2
dec dx
mov cx,14
loop323:
push cx
mov cx,di

sub cx,12
mov al,0bh
int 10h
mov al,00h
dec dx
pop cx
loop loop323

mov ax,0c0bh
mov dx,si
mov cx,13
sub di,12
loop324:
add cx,di
int 10h
sub cx,di
loop loop324

mov dh,initrow
mov cl,16
mov al,dh
mul cl
mov si,ax
dec si

mov ch,initcol
mov cl,8
mov al,ch
mul cl
mov di,ax
dec di

mov ax,0c0bh
mov dx,si
add dx,14
mov cx,15
loop325:
add cx,di
int 10h
sub cx,di
loop loop325

mov dx,si
mov cx,15
add di,14
loop326:
push cx
mov cx,di
int 10h
inc dx
pop cx
loop loop326

sub di,2
dec dx
mov cx,13
loop327:
push cx
mov cx,di

sub cx,12
mov al,0bh
int 10h
mov al,00h
dec dx
pop cx
loop loop327

mov ax,0c0bh
mov dx,si
mov cx,12
sub di,11
loop328:
add cx,di
int 10h
sub cx,di
loop loop328

ret
man2 endp




man1 proc near
mov ax,data
mov es,ax

mov dh,initrow
mov cl,16
mov al,dh
mul cl
mov si,ax

mov ch,initcol
mov cl,8
mov al,ch
mul cl
mov di,ax

mov ax,0c09h
mov dx,si
add dx,15
mov cx,16
loop311:
add cx,di
int 10h
sub cx,di
loop loop311

mov dx,si
mov cx,16
add di,15
loop312:
push cx
mov cx,di
int 10h
inc dx
pop cx
loop loop312

sub di,2
dec dx
mov cx,14
loop313:
push cx
mov cx,di

sub cx,12
mov al,09h
int 10h
mov al,00h
dec dx
pop cx
loop loop313

mov ax,0c09h
mov dx,si
mov cx,13
sub di,12
loop314:
add cx,di
int 10h
sub cx,di
loop loop314

mov dh,initrow
mov cl,16
mov al,dh
mul cl
mov si,ax
dec si

mov ch,initcol
mov cl,8
mov al,ch
mul cl
mov di,ax
dec di

mov ax,0c09h
mov dx,si
add dx,14
mov cx,15
loop315:
add cx,di
int 10h
sub cx,di
loop loop315

mov dx,si
mov cx,15
add di,14
loop316:
push cx
mov cx,di
int 10h
inc dx
pop cx
loop loop316

sub di,2
dec dx
mov cx,13
loop317:
push cx
mov cx,di

sub cx,12
mov al,09h
int 10h
mov al,00h
dec dx
pop cx
loop loop317

mov ax,0c09h
mov dx,si
mov cx,12
sub di,11
loop318:
add cx,di
int 10h
sub cx,di
loop loop318

ret
man1 endp




man proc near
mov ax,data
mov es,ax

mov dh,10
mov cl,16
mov al,dh
mul cl
mov si,ax

mov ch,24
mov cl,8
mov al,ch
mul cl
mov di,ax

mov ax,0c09h
mov dx,si
add dx,15
mov cx,16
loop61:
add cx,di
int 10h
sub cx,di
loop loop61

mov dx,si
mov cx,16
add di,15
loop62:
push cx
mov cx,di
int 10h
inc dx
pop cx
loop loop62

sub di,2
dec dx
mov cx,14
loop63:
push cx
mov cx,di

sub cx,12
mov al,09h
int 10h
mov al,00h
dec dx
pop cx
loop loop63

mov ax,0c09h
mov dx,si
mov cx,13
sub di,12
loop64:
add cx,di
int 10h
sub cx,di
loop loop64

mov dh,10
mov cl,16
mov al,dh
mul cl
mov si,ax
dec si

mov ch,24
mov cl,8
mov al,ch
mul cl
mov di,ax
dec di

mov ax,0c09h
mov dx,si
add dx,14
mov cx,15
loop65:
add cx,di
int 10h
sub cx,di
loop loop65

mov dx,si
mov cx,15
add di,14
loop66:
push cx
mov cx,di
int 10h
inc dx
pop cx
loop loop66

sub di,2
dec dx
mov cx,13
loop67:
push cx
mov cx,di

sub cx,12
mov al,09h
int 10h
mov al,00h
dec dx
pop cx
loop loop67

mov ax,0c09h
mov dx,si
mov cx,12
sub di,11
loop68:
add cx,di
int 10h
sub cx,di
loop loop68

ret
man endp




aim proc near
mov ax,data
mov es,ax
mov si,offset circle
call show
mov col,28
call show
mov col,30
call show

ret
aim endp


show proc near
push ax
push bx
push cx
push dx
push si
push bp

mov num1,0

  push ax
  mov al,row
  mov bl,16
  mul bl
  mov dx,ax
  pop ax

  mov bh,0    ;页
mov bp,16  ;外圈(行) ,垂直点数
sh0:

  push bp
  mov bp,16  ;内圈(列),水平点数

  push ax
  mov al,col
  mov bl,8
  mul bl
  mov cx,ax
  pop ax

  mov ax,[si] ;取值
xchg al,ah  ;交换
mov di,ax
  mov ah,0ch

inc num1
cmp num1,1
ja color1
mov al,00001011b
jmp sh2

color1:
cmp num1,8
jc color2

  mov al,00001011b
jmp sh2


color2:
mov al,00000000b

sh2:
  shl di,1  ;移出到 cf
jnc sh3 ;无点

int 10h ;有点印出
sh3:   
  inc cx  ;下一点
dec bp  ;完了一列?
jnz sh2 ;未
add si,2 ;下一行
pop bp  ;
inc dx  ;坐标移下一行

dec bp  ;行回圈
jnz sh0

pop bp
pop si
pop dx
pop cx
pop bx
pop ax

ret
show endp

code ends
end start




上一篇:这一回学会多媒体指令
下一篇:国外找的MFC虚拟列表用法轻松加载100万数据
您需要登录后才可以回帖 登录 | 加入驿站 qq_login

本版积分规则

×【发帖 友情提示】
1、请回复有意义的内容,请勿恶意灌水;
2、纯数字、字母、表情等无意义的内容系统将自动删除;
3、若正常回复后帖子被自动删除,为系统误删的情况,请重新回复其他正常内容或等待管理员审核通过后会自动发布;
4、感谢您对VC驿站一如既往的支持,谢谢合作!

关闭

站长提醒上一条 /2 下一条

QQ|小黑屋|手机版|VC驿站 ( 辽ICP备09019393号 )|网站地图wx_jqr

GMT+8, 2020-10-27 15:04

Powered by CcTry.CoM

© 2009-2020 cctry.com

快速回复 返回顶部 返回列表