?? menu.asm
字號:
include macro.asm
extrn sound:far,piano:far,my:far,love:far,tiger:far
STACK SEGMENT PARA STACK 'STACK'
DB 64 DUP('STACK')
STACK ENDS
data segment
scrmm db 110 dup(?)
mainmenu1 db 'Help'
mainmenu2 db 'One'
mainmenu3 db 'Two'
mainmenu4 db 'Three'
mainmenu5 db 'Four'
;主菜單Help下的子菜單名
submenu11 db 'About'
submenu12 db 'Me'
submenu13 db 'Exit'
;主菜單One下的子菜單名
submenu21 db 'Read'
submenu22 db 'Hear'
submenu23 db 'Exit'
;主菜單Two下的子菜單名
submenu31 db 'Read'
submenu32 db 'Hear'
submenu33 db 'Exit'
;主菜單Three下的子菜單名
submenu41 db 'Read'
submenu42 db 'Hear'
submenu43 db 'Exit'
;主菜單Four下的子菜單名
submenu51 db 'Read'
submenu52 db 'Play'
submenu53 db 'Exit'
;歡迎窗口信息
msgtitle db 'JJ022 Wei Chunrong'
escape db 'Press ESC to exit.'
over db '* Thank you for using...Good buy *';退出窗口信息
text1 db 'Please press Enter (',11h,0c4h,0d9h,') to close the submenu.'
text2 db 'Please press ',1bh,' or ',1ah,' to select the mainmenu.'
text3 db 'Please press ',18h,' or ',19h,' to select the submenu.'
text4 db '**********************************************************************'
sub11 db 'This assembler is formed by four pieces of music. '
sub12 db 'Please operate according to the explanation. '
sub13 db 'My name is Wei Chunrong and my student number is 21071219 '
sub21 db '____________________ Two Tigers _________________________'
sub22 db 'Listening ...'
sub31 db ' Life And Death Is Interdependent I Long For You Bitterly. '
sub32 db 'Listening ...'
sub41 db '________________ I And My Motherland ____________________'
sub42 db 'Listening ...'
sub51 db '___________________ Play The Piano ______________________'
sub52 db 'Please according to the figure of 1 to 8 , let us have a try of.'
mainnum db 1 ;主菜單序列號
subnum db ? ;子菜單序列號
subshow db 0 ;為0時子菜單未顯示
mainindex db ? ;主菜單字符長度
data ends
;--------------------------------
code segment
assume cs:code,ds:data,es:data
main proc far
start:
mov ax,data
mov ds,ax
mov es,ax
;******************* 初始化屏幕開始
mov ah,0
mov al,03h
int 10h
;******************* 初始化屏幕結束
showcur 10h ;隱藏光標
;************************************* 開始主窗口的繪制
drawwindow 1eh,0,0,24,79
drawwindow 1eh,0,0,24,79
drawwindow 70h,0,0,0,79
drawwindow 70h,24,0,24,79
setpos 1,0
windowtandb 0d5h,0cdh,0b8h,1,0,80,1eh
mov al,2
draw:
windowlandr 0b3h,al,0,80,1eh
inc al
cmp al,17h
jne draw
windowtandb 0c0h,0c4h,0d9h,23,0,80,1eh
outputstr escape,18,24,3,70h
;***************************************開始主菜單的繪制
setpos 0,3
outputstr mainmenu1,4,0,3,70h
changemenu 0,3,1,74h
outputstr mainmenu2,3,0,13,70h
changemenu 0,13,1,74h
outputstr mainmenu3,3,0,23,70h
changemenu 0,23,1,74h
outputstr mainmenu4,5,0,33,70h
changemenu 0,33,1,74h
outputstr mainmenu5,4,0,43,70h
changemenu 0,43,1,74h
setpos 0,3
;*********************************** 菜單上的說明
outputstr text1,46,3,13,17h
changemenu 3,26,11,1dh
outputstr text2,43,4,13,17h
changemenu 4,26,1,1dh
changemenu 4,31,1,1dh
outputstr text3,42,5,13,17h
changemenu 5,26,1,1dh
changemenu 5,31,1,1dh
outputstr text4,70,7,4,17h
changemenu 7,4,70,1ah
call prsright
call prsleft
input:;消息接收循環
mov ah,0
int 16h
cmp ah,01h
jne continue1
call exit
jmp input
continue1:
cmp ah,4bh
jne continue2
call prsleft
jmp input
continue2:
cmp ah,4dh
jne continue3
call prsright
jmp input
continue3:
cmp ah,50h
jne continue4
call prsdown
jmp input
continue4:
cmp ah,48h
jne continue5
call prsup
jmp input
continue5:
cmp ah,1ch
jne continue6
call prsenter
jmp input
continue6: jmp input
;-----------------
prsenter proc near;按下ENTER鍵
cmp subshow,0
jne enter1
call prsdown
ret
enter1:
mov al,mainnum
push ax
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
dec mainnum
writescr mainnum,scrmm
inc mainnum
setpos 0,mainnum
pop ax
mov mainnum,al
drawwindow 13h,22,4,22,50
cmp mainnum,1
jne prsenter1
cmp subnum,2
jne entersub12
outputstr sub11,49,14,10,1ch
outputstr sub12,45,16,10,1ch
entersub12:
cmp subnum,3
jne entersub13
outputstr sub13,57,18,10,1dh
entersub13:
cmp subnum,4
jne prsenter1
call exit
prsenter1:
cmp mainnum,2
jne prsenter2
cmp subnum,2
jne entersub22
outputstr sub21,58,10,10,1eh ;字符串,個數,行,列,顏色
entersub22:
cmp subnum,3
jne entersub23
outputstr sub22,13,12,28,1ch
call tiger
jmp start
entersub23:
cmp subnum,4
jne prsenter2
call exit
prsenter2:
cmp mainnum,3
jne prsenter3
cmp subnum,2
jne entersub32
outputstr sub31,58,10,10,1eh
entersub32:
cmp subnum,3
jne entersub33
outputstr sub32,13,12,28,1ch
call love
jmp start
entersub33:
cmp subnum,4
jne prsenter3
call exit
prsenter3:
cmp mainnum,4
jne prsenter4
cmp subnum,2
jne entersub42
outputstr sub41,58,10,10,1eh
entersub42:
cmp subnum,3
jne entersub43
outputstr sub42,13,12,28,1ch
call my
jmp start
entersub43:
cmp subnum,4
jne prsenter4
call exit
prsenter4:
cmp mainnum,5
jne prsenter5
cmp subnum,2
jne entersub52
outputstr sub51,58,10,10,1eh
entersub52:
cmp subnum,3
jne entersub53
call color
call piano
jmp start
entersub53:
cmp subnum,4
jne prsenter5
call exit
prsenter5:
mov subshow,0
ret
prsenter endp
;----------------
color proc near
outputstr sub52,64,12,8,17h
changemenu 12,42,1,1ch
changemenu 12,47,1,1ch
changemenu 12,72,1,17h
ret
color endp
;----------------
halt proc near
mov al,mainnum
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
cmp subshow,1
jne hshow
dec mainnum
writescr mainnum,scrmm
inc mainnum
hshow:
readscr 42,scrmm
submenu 42,submenu51,4,submenu52,4,submenu53,4,9
changemenu 0,mainnum,5,70h
changemenu 0,mainnum,1,74h
mov mainnum,05h
changemenu 0,43,4,0fh
changemenu 2,44,6,0fh
mov subnum,2
mov subshow,1
setpos 0,43
ret
halt endp
;----------------
dalt proc near;
mov al,mainnum
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
cmp subshow,1
jne dshow
dec mainnum
writescr mainnum,scrmm
inc mainnum
dshow:
readscr 32,scrmm
submenu 32,submenu41,4,submenu42,4,submenu43,4,9
changemenu 0,mainnum,5,70h
changemenu 0,mainnum,1,74h
mov mainnum,04h
changemenu 0,33,5,0fh
changemenu 2,34,6,0fh
mov subnum,2
mov subshow,1
setpos 0,33
ret
dalt endp
;----------------
ralt proc near
mov al,mainnum
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
cmp subshow,1
jne rshow
dec mainnum
writescr mainnum,scrmm
inc mainnum
rshow:
readscr 22,scrmm
submenu 22,submenu31,4,submenu32,4,submenu33,4,9
changemenu 0,mainnum,5,70h
changemenu 0,mainnum,1,74h
mov mainnum,03h
changemenu 0,23,3,0fh
changemenu 2,24,6,0fh
mov subnum,2
mov subshow,1
setpos 0,23
ret
ralt endp
;----------------
ealt proc near
mov al,mainnum
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
cmp subshow,1
jne eshow
dec mainnum
writescr mainnum,scrmm
inc mainnum
eshow:
readscr 12,scrmm
submenu 12,submenu21,4,submenu22,4,submenu23,4,9
changemenu 0,mainnum,5,70h
changemenu 0,mainnum,1,74h
mov mainnum,02h
changemenu 0,13,3,0fh
changemenu 2,14,6,0fh
mov subnum,2
mov subshow,1
setpos 0,13
ret
ealt endp
;----------------
falt proc near;
mov al,mainnum
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
cmp subshow,1
jne fshow
dec mainnum
writescr mainnum,scrmm
inc mainnum
fshow:
readscr 2,scrmm
submenu 2,submenu11,5,submenu12,2,submenu13,4,9
changemenu 0,mainnum,5,70h
changemenu 0,mainnum,1,74h
mov mainnum,01h
changemenu 0,3,5,0fh
changemenu 2,4,6,0fh
mov subnum,2
mov subshow,1
setpos 0,3
ret
falt endp
;----------------
prsup proc near; 按上箭頭
cmp subshow,0
jne prsup2
ret
prsup2:
mov al,mainnum
push ax
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
changemenu subnum,mainnum,8,70h
inc mainnum
changemenu subnum,mainnum,1,74h
pop ax
mov mainnum,al
cmp subnum,02h
jne prsuptop
mov subnum,04h
jmp prsup1
prsuptop:
dec subnum
prsup1:
mov al,mainnum
push ax
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
changemenu subnum,mainnum,8,0fh
pop ax
mov mainnum,al
ret
prsup endp
;----------------
prsdown proc near; 按下箭頭
cmp subshow,0
jne prsdown2
cmp mainnum,1
jne prsdown3
call falt
jmp prsdown7
prsdown3:
cmp mainnum,2
jne prsdown4
call ealt
jmp prsdown7
prsdown4:
cmp mainnum,3
jne prsdown5
call ralt
jmp prsdown7
prsdown5:
cmp mainnum,4
jne prsdown6
call dalt
jmp prsdown7
prsdown6:
call halt
prsdown7:
ret
prsdown2:
mov al,mainnum
push ax
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
changemenu subnum,mainnum,8,70h
inc mainnum
changemenu subnum,mainnum,1,74h
pop ax
mov mainnum,al
cmp subnum,04h
jne prsdownbot
mov subnum,02h
jmp prsdown1
prsdownbot:
inc subnum
prsdown1:
mov al,mainnum
push ax
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
changemenu subnum,mainnum,8,0fh
pop ax
mov mainnum,al
ret
prsdown endp
;----------------
prsright proc near; 按右箭頭
cmp subshow,0
je prsright1
call prsrgtsub
ret
prsright1:
mov al,mainnum
push ax
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
changemenu 0,mainnum,5,70h
changemenu 0,mainnum,1,74h
pop ax
mov mainnum,al
cmp mainnum,05h
jne prsright2
mov mainnum,01h
jmp prsright3
prsright2:
inc mainnum
prsright3:
cmp mainnum,1
je prsright4
cmp mainnum,2
je prsright4
cmp mainnum,5
je prsright4
cmp mainnum,3
je prsright5
cmp mainnum,4
je prsright6
prsright4:
mov mainindex,4
jmp prsright7
prsright5:
mov mainindex,3
jmp prsright7
prsright6:
mov mainindex,5
prsright7:
mov al,mainnum
push ax
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
changemenu 0,mainnum,mainindex,0fh
pop ax
mov mainnum,al
ret
prsright endp
;----------------
prsrgtsub proc near;當子菜單打開時按右箭頭
cmp mainnum,1
jne prsrgt1
call ealt
jmp prsrgt5
prsrgt1:
cmp mainnum,2
jne prsrgt2
call ralt
jmp prsrgt5
prsrgt2:
cmp mainnum,3
jne prsrgt3
call dalt
jmp prsrgt5
prsrgt3:
cmp mainnum,4
jne prsrgt4
call halt
jmp prsrgt5
prsrgt4:
call falt
prsrgt5:
ret
prsrgtsub endp
;----------------
prsleft proc near;按左箭頭
cmp subshow,0
je prsleft1
call prslftsub
ret
prsleft1:
mov al,mainnum
push ax
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
changemenu 0,mainnum,5,70h
changemenu 0,mainnum,1,74h
pop ax
mov mainnum,al
cmp mainnum,01h
jne prsleft2
mov mainnum,05h
jmp prsleft3
prsleft2:
dec mainnum
prsleft3:
cmp mainnum,1
je prsleft4
cmp mainnum,2
je prsleft4
cmp mainnum,5
je prsleft4
cmp mainnum,3
je prsleft5
cmp mainnum,4
je prsleft6
prsleft4:
mov mainindex,4
jmp prsleft7
prsleft5:
mov mainindex,3
jmp prsleft7
prsleft6:
mov mainindex,5
prsleft7:
mov al,mainnum
push ax
mov cl,0ah
mul cl
sub ax,07h
mov mainnum,al
changemenu 0,mainnum,mainindex,0fh
pop ax
mov mainnum,al
ret
prsleft endp
;----------------
prslftsub proc near;當子菜單打開時按左箭頭
cmp mainnum,1
jne prslft1
call halt
jmp prslft5
prslft1:
cmp mainnum,2
jne prslft2
call falt
jmp prslft5
prslft2:
cmp mainnum,3
jne prslft3
call ealt
jmp prslft5
prslft3:
cmp mainnum,4
jne prslft4
call ralt
jmp prslft5
prslft4:
call dalt
prslft5:
ret
prslftsub endp
exit proc near;退出子過程
drawwindow 1eh,0,0,24,79
outputstr msgtitle,18,9,29,1dh
setpos 9,26
outputchar ' ',93h,1
setpos 9,49
outputchar ' ',93h,1
outputstr over,34,11,21,1fh
mov ah,07h
int 21h
mov ah,0
mov al,03h
int 10h
mov ah,4ch
int 21h
ret
exit endp
ret
main endp
code ends
end main
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -