Load Proc Near
Load key on the screen
CMP Keyflag, 00h; judgment is a bass key
JNZ load_hgh; continue to judge
LEA SI, ST_LX; load the start address of the bass key
Lea di, ed_lx; load the bass key to end the head address
JMP load_end; load end
LOAD_HGH:
CMP keyflag, 02h; judgment is a treble key
JNZ LOAD_MID; continue to judge
Lea Si, ST_HX; loaded into the top address of the start
Lea di, ed_hx; loaded with a top key button
JMP load_end
LOAD_MID:
LEA SI, ST_MX; loaded in the spiral start sites
Lea di, ed_mx; load the middle sound button ends the first address
Load_end:
RET
Load Endp
Scan_Key Proc Near
; Check the state of the button, and store the corresponding variables and registers
MOV Si, 100
MOV Di, 100
Mov Keynum, 100; assignment
MOV AH, 0; read keyboard
INT 16H
MOV DL, AH
Call scan_song; judgment whether it is an automatic play button (large keyboard number button 1 ~ 5)
Call scan_tune; judgment is a C / D command button
Call freq_change; judgment if the frequency change button is pressed: ( /- symbol)
CMP AH, 01H; Whether it is the end key
JNE flag_scan; if not continuing to detect
Call exit;
Flag_scan:
MOV AH, 02H; read keyboard status bytes
INT 16H
MOV DH, Al; judgment is right Shift key
And dh, 01h
CMP DH, 01H
JE SLOW;
MOV DH, Al; not judge whether it is a left Shift key
And DH, 02H
CMP DH, 02H
JE SHGH; Yes, the treble processing JMP SMID; is not a midrange process
Slow:; Bass Processing
Mov Audio, 1
Mov Keyflag, 0
JMP key_1; jump to sound keys
SHGH:;
Mov Audio, 3
Mov Keyflag, 2
JMP key_1; jump to sound keys
SMID:;
Mov Audio, 2
Mov Keyflag, 1
Key_1:
CMP DL, 4FH; is it 1
JNE KEY_2; Continue judgment
Mov keynum, 0; not saving flag
JMP scan_end; key scan end
Key_2:
CMP DL, 50H; is it 2
JNE KEY_3
Mov Keynum, 2
JMP scan_end
Key_3:
CMP DL, 51H; is it 3
JNE KEY_4
Mov Keynum, 4
JMP scan_end
Key_4:
CMP DL, 4BH; is 4
JNE KEY_5
Mov Keynum, 6
JMP scan_end
Key_5:
CMP DL, 48H; is it 5
JNE KEY_6
Mov Keynum, 8
JMP scan_end
Key_6:
CMP DL, 4DH; is it 6
JNE KEY_7
Mov Keynum, 10
JMP scan_end
Key_7:
CMP DL, 47h; is it 7
JNE SCAN_END
Mov Keynum, 12
SCAN_END:
RET
Scan_Key Endp
Scan_song proc Near
; Judgment is whether it is an automatic play button (key 1 ~ 5), and save the flag variable (SONG)
; In: AH key scan code
Push AX
MOV SONG, 100; assigning initial value
CMP AH, 3BH; and 1 Comparison
JB SONG_END; less than 1 ends CMP AH, 3FH; and 5 Compare
JA SONG_END;
SUB AH 3B; Convert to 1 ~ 5
MOV
Al
AH
MOV AH, 00H
MOV SONG, AX; Deposit Sign Code
Song_end:
POP AX
RET
SCAN_SONG ENDP
Play_song proc near
Select and play music
Push BP
Push Si
Push bx
Push di
Push AX
CMP SONG, 01H; Judgment is a song 1
JNE GO2; not continuing judgment
Call Song_light_off; lamp 1 ~ 5
Draw 247, 42, 251, 46, 0Eh; Light 1 bright
Lea BP, MUS_TIME1; load delay data first address
Lea Si, Mus_FREQ1; load frequency data first address
JMP FREQ
GO2:
CMP SONG, 02H; Judgment is a song 2
JNE GO3
Call Song_light_off
Draw 253, 42, 257, 46, 0EH
Lea BP, MUS_TIME2
Lea Si, MUS_FREQ2
JMP FREQ
GO3:
CMP SONG, 03H; Judgment is a song 3
JNE GO4
Call Song_light_off
Draw 259, 42,263,46,0eh
Lea BP, MUS_TIME3
Lea Si, MUS_FREQ3
JMP FREQ
GO4:
CMP SONG, 04H; Judgment is a song 4
JNE GO5
Call Song_light_off
Draw 265, 42, 269, 46, 0EH
Lea BP, MUS_TIME4
Lea Si, Mus_FREQ4
JMP FREQ
GO5:
CMP SONG, 05H; Judgment is a song 5
JNE FREQ
Call Song_light_off
Draw 271, 42, 275, 46, 0EH
Lea BP, MUS_TIME5
Lea Si, MUS_FREQ5
FREQ:
MOV AH, 01H; read keyboard buffer characters
INT 16H
CMP AH, 1CH; Whether is an Enter key
JNZ Continue; not continuing JMP play_end; is the automatic play
CONTINUE:
MOV AH, 0CH; Clear keyboard buffer characters
MOV Al, 06H
Int 21h
MOV Di, [Si]
CMP Di, -1; judgment end No
JE Play_end
MOV BX, [BP]
Call Gen_Auto; Voice
Add Si, 2
Add BP, 2; Next frequency
JMP FREQ
Play_end:
Call Song_light_off
POP AX
POP DI
POP BX
POP Si
POP BP
RET
Play_song endp