?? interface.asm
字號:
;*********************************************************
;滾動窗體宏定義
win MACRO lux,luy,rdx,rdy,attr
MOV AH,6
MOV AL,0
MOV BH,attr ;前景背景屬性
MOV CH,lux
MOV CL,luy
MOV DH,rdx
MOV DL,rdy
INT 10h
ENDM
;滾動窗體宏定義2
win2 MACRO lal,lux,luy,rdx,rdy,attr
MOV AH,6
MOV AL,lal
MOV BH,attr ;前景背景屬性
MOV CH,lux
MOV CL,luy
MOV DH,rdx
MOV DL,rdy
INT 10h
ENDM
saveE MACRO
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH DS
PUSH SI
ENDM
recover MACRO
POP SI
POP DS
POP DX
POP CX
POP BX
POP AX
ENDM
fileIO MACRO X,Y
LEA DX,X
MOV AH,Y
INT 21H
ENDM
showM MACRO messM
poscur 24,0
LEA DX,messM
MOV AH,09H
INT 21H
ENDM
;------------------------------------
;字符串顯示宏定義
show MACRO mess
LEA DX,mess
MOV AH,09h
INT 21h
ENDM
;-------------------------------------
;光標定位宏定義
posget MACRO ;讀光標位置
MOV AH,03h
MOV BH,0
INT 10h
ENDM
posgetS MACRO
saveE
MOV AH,03h
MOV BH,0
INT 10h
MOV row,DH
MOV column,DL
recover
ENDM
poscur MACRO x,y
MOV AH,2
MOV DH,x
MOV DL,y
MOV BH,0
INT 10h
ENDM
;-------------------------------------
;讀取鍵盤
readChar MACRO
MOV BH,0
MOV AH,8h
INT 10h
ENDM
putchar MACRO x
MOV DL,x
MOV AH,02H
INT 21H
ENDM
getchar MACRO
MOV AH,0
INT 16h
ENDM
;*************************************************
;********************************************************
;EXTRN fileProc:NEAR
;數據段定義
; .386
data_seg SEGMENT
totalChars DB 0 ;字符總數,以此來控制數據緩沖區,
CHar1 DB 0b3h ;常量,是一個豎線
tempchar DB ? ;臨時字節變量
musicInt DB 0 ;文件數量
musicIndex DB 30h ;默認文件名的最后一個字符,隨新建打開而增1,關閉減1
SaveAsFlag DB 0 ;已調用過filesaveas函數
modifyFlag DB 0 ;為0時已做修改
AsOrIfFlag DB 0 ;為0時是saveas調用
saveActive DB 78h ;根據musicInt來判斷是否激活save,saveAs菜單
copyActive DB 78h ;根據copyFlag來判斷是否激活copy,cut菜單
pasteActive DB 78h ;根據paste來判斷是否激活paste菜單
CLearFlag DB 0 ;clearFlag為0時表示不需要處理選擇文本,如將反色顯示還原
pasteFlag DB 0 ;pasteFlag為0時為不能粘貼,
copyFlag DB 0 ;copyFlag為0時為不能復制與剪切,
pasteNum DB 0 ;粘貼緩沖區中字符個數.
PasteBuffer DB 25 DUP (0)
DB '$'
;復制粘貼緩沖區
INsertNum DB 1 ;insertNum為插入字符的個數
save DB 0 ;
path DB 30 DUP (0) ;文件名存放緩沖區
DB '$'
buffer DB 2000 DUP(?) ;buffer為數據緩沖區
bak DB 3850 DUP(0) ;視頻緩沖區的備份
row DB 2 ;保存行號,
column DB 1 ;保存列號.
rowBak DB 2
columnbak DB 1
peak DB 0Dah, 78 DUP(0C4h) ,0BFh,13,10,'$' ;頂端橫線
errormess1 DB 'can not creat the file,path is wrong! ','$'
errormess2 DB 'can not write to the file! ','$'
errormess3 DB 'the filename is too long! ','$'
errormess4 DB 'can not open the file,filename is wrong','$'
errormess5 DB 'can not read the file! ','$'
mess1 DB 'Please input save file name:','$'
mess2 DB ' Please input open file name:','$'
mess3 DB ' ***The file is not save! Save it now? (Y/N)***: ','$'
mess4 DB 'please input the filename again ','$'
mess5 DB 'your put is wrong!please input Y/N again','$'
mess6 DB 0b3H,' row:??? column:???','$'
mess7 DB 'Creat a new file ','$'
mess8 DB 'loads an exiting file from disk ','$'
mess9 DB 'save current file ','$'
mess10 DB 'save current file with new name ','$'
mess11 DB 'Exits the editor ','$'
mess12 DB 'F1:file menu F2:Play Music F3:help ','$'
mess21 DB 'Copy selected text to buffer ','$'
mess22 DB 'Deletes selected text and copys it ','$'
mess23 DB 'Inserts buffer contents here ','$'
mess13 DB 0b3H,'modified ','$'
mess14 DB 0b3h,'NoModified','$'
mess15 DB ' editing... press Esc can escape ','$'
mess16 DB ' IBM PC Assemble Language Course Design',13,10,'$'
mess17 DB ' MusicEdit 1.0 ',13,10,'$'
mess18 DB ' Made by GuSui etc. ',13,10,'$'
mess19 DB ' Dec,30,2004 ',13,10,'$'
mess20 DB ' Press any keys to return','$'
musicname DB 'd:\music0',0
RF DB 13,10,'$'
music DW 2 DUP(262,294,330,262) ;兩只老虎
DW 2 DUP(330,349,392)
DW 2 DUP(392,440,392,349,330,262)
DW 2 DUP(294,196,262),0
time DW 8 DUP(4)
DW 2 DUP(4,4,8)
DW 2 DUP(2,2,2,2,4,4)
DW 2 DUP(4,4,8)
music1 DW 262,294,330,349,392,440,494,523 ;音階
DW 523,494,440,392,349,330,294,262,0
time1 DW 16 DUP(25)
;文件相關數據定義
handler DW 0
filename DB 'e:/tiger.vol',0
CHartemp DB 0
Buffertemp DB 4 DUP(0)
Bufferflag DW 0
musicFinish DB 0
musicTemp DW 0
times DW 1
musicBuffer DW 100 DUP(0)
bufferIndex DW 0
timeBuffer DW 100 DUP(0)
;菜單數據定義
str_menu DB ' File(F1) Play(F2) Edit(F3) Help(F4)',13,10,'$'
file_0 DB 0dah , 11 DUP(0C4H),0BFH ,13,10,'$'
file_1 DB 0B3H,' New ',0B3H,13,10,'$'
file_2 DB 0B3H,' Open ',0B3H,13,10,'$'
file_3 DB 0B3H,' Save ',0B3H,13,10,'$'
file_4 DB 0B3H,' Save as ',0B3H,13,10,'$'
file_5 DB 0B3H,' Exit ',0B3H,13,10,'$'
file_6 DB 0c0H, 11 DUP(0c4h),0d9H,13,10,'$'
play_0 DB 0dah , 10 DUP(0C4H),0BFH ,13,10,'$'
play_1 DB 0B3H,' tiger ',0B3H,13,10,'$'
play_2 DB 0B3H,' music2 ',0B3H,13,10,'$'
play_3 DB 0B3H,' scale ',0B3H,13,10,'$'
play_4 DB 0B3H,' gun ',0B3H,13,10,'$'
play_5 DB 0c0H, 10 DUP(0c4h),0d9H,13,10,'$'
edit_0 DB 0dah , 10 DUP(0C4H),0BFH ,13,10,'$'
edit_1 DB 0B3H,' Copy ',0B3H,13,10,'$'
edit_2 DB 0B3H,' cut ',0B3H,13,10,'$'
edit_3 DB 0B3H,' Paste ',0B3H,13,10,'$'
edit_4 DB 0c0H, 10 DUP(0c4h),0d9H,13,10,'$'
error0 DB 'Open File failed',13,10,'$'
error1 DB 'the file have illegal character', 13,10,'$'
error2 DB 'the file have illegal character2', 13,10,'$'
data_seg ENDS
;*********************代碼段*************8
code_seg SEGMENT
ASSUME CS:code_seg,DS:data_seg
;************主過程開始**************
start:
MOV AX,data_seg
MOV DS,AX
CALL welcome
INit:
CALL INitwin
GEtchar ;讀鍵盤
CMP AH,3bh ;F1
JZ showFile
CMP AH,3ch ;F2
JZ showPlay
CMP AH,3dh
JZ showE
CMP AH,3Eh ;F3
JZ showh
CMP AH,01h
JZ exitf
JMP INit
showFile: CALL showmenuF
JMP INit
showPlay: CALL showMenuP
JMP INit
showE: CALL showMenuE
JMP INit
showh: CALL showmenuh
JMP INit
exitf:
MOV AH, 4ch
INT 21h
;主執行代碼結束,下面都是要調用的函數定義.
;***********************************
;**********歡迎模塊*****************
welcome PROC
saveE
recover
RET
welcome ENDP
;----------------------------
;***********初始化模塊*******
;功能:初始化屏幕,顯示菜單,提示信息,設置工作模式為3號字符模式
;****************************
INitwin PROC
saveE
MOV AH,01h
MOV CH,03h
INT 10h ;設置為字符模式03
win 0,0,24,79,70h ;清屏
win 1,0,23,79,07h
win 2,1,23,78,27H
poscur 0,0
show str_menu
poscur 1,0
show peak ;顯示上面的橫線
;兩個循環是畫左右兩條線的.
MOV CL,23
LOOPf:
poscur CL,0
putchar CHar1
DEC CL
CMP CL,1
JNZ LOOPf
LOOPf2:
INC CL
poscur CL,79
putchar CHar1
CMP CL,23
JNZ LOOPf2
poscur 2,1
posgets
CALL showRC
poscur 24,1
show mess12
poscur 2,1
recover
RET
INitwin ENDP
;*************************************
;************************************
;********文件菜單模塊*****************
;功能:當在主過程或編輯狀態檢測到F1而被激活的.根據用戶的選擇來
; 執行相應的菜單命令
;入口參數有musicInt:文件數量,以此來判斷是激活save,save as 菜單
;先保存視頻緩沖區的內容 ,再獲取鍵盤輸入,按照輸入跳到不同的分支,
;每個分支都調用相應的函數來處理.
;to*為當前選中項*的處理分支
;to*&,其中&是數字,為了解決匯編中的一些跳轉指令分幾次跳的問題,
showmenuF PROC
saveE
CALL savedisplay
CMP musicInt,0
JZ NOTactive
MOV saveActive,79h
JMP activeOK
notactive:
MOV saveActive,78h
activeOK:
win 0,3,0,11,07h
poscur 0,0
show str_menu
win 2,3,8,15,saveActive ;菜單不選中的顏色(白底黑字)
win 9,4,9,16,07h ;菜單的陰影
win 3,16,9,16,07h ;菜單的陰影
;顯示各個菜單,并設置第一個菜單為默認項,
poscur 2,3
show file_0
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -