Is in a key press after success, record is successful, then don't let go of the first in the second, unable to record the second,
Press release records only one, how to do light press record
CodePudding user response:
Perhaps your code "logic problem"...CodePudding user response:
Fyi:CODE SEGMENT 'CODE'
ASSUME CS: CODE, DS: CODE, ES: CODE, SS: CODE
EndFlag DB 0
Int9Enter PROC FAR
STI
PUSH the BP
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH the DS
PUSH ES
PUSH CS
POP ES
CLD
MOV AX, 0 f000h
MOV DS, AX
MOV SI, 0 fffeh
CMP BYTE PTR [SI], 0 FCH; PC/AT?
PUSH CS
POP the DS
JNZ $PCXT1
MOV CS: BYTE PTR PCAT, 01
MOV AL, 0 adh; Select 8042 for Scan Code
-CALL the SetKey
CLI
CX, XOR CX
$J1:
IN AL, 64 h; Test 8042 Ready?
LOOPNZ $J1
IN AL, 60 h; The Get Scan Code
-STI
CMP AL, 0 feh
JZ $J2; Jmp To Control Char
CMP AL, 0 fah
JNZ $J3
$J2: JMP $Exit1
;
$PCXT1:
IN AL, 60 h; Get a PC/XT Scan Code
-$J3:
; D7=0 - Down 1 - Up
CMP AL, 1; [ESC] KEY
JZ $End
CALL ShowCode
CALL Music
JMP $Exit1
CS: $End: MOV BYTE PTR EndFlag, 1
;
$Exit1:
CALL AllowKey
POP ES
POP the DS
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
POP BP
CLI
IRET
;
PCAT DB 0; 0-1 - PC/PC/XT AT
0123456789 DB 'abcdef'
Int9Enter ENDP
;
;
The SetKey PROC NEAR
PUSH AX
CLI
CX, SUB CX
$SET:
IN AL, 64 h
The TEST of AL, 02
LOOPNZ $SET
POP AX
OUT of 64 h, AL
STI
RET
The SetKey ENDP
;
;
AllowKey PROC NEAR
CLI
MOV AL, 20 h
OUT of 20 h, AL
CMP CS: BYTE PTR PCAT, 00
JZ $PCXT2
MOV AL, 0 aeh
CALL the SetKey
RET
;
$PCXT2:
IN AL, 61 h
MOV AH, AL
The OR AL, 80 h
OUT of 61 h, AL
XCHG AH, AL
OUT of 61 h, AL
RET
AllowKey ENDP
;
ShowCode PROC
PUSH AX
PUSH AX
MOV CL, 4
SHR AL and CL
XOR BH, BH
MOV BL, AL
MOV AL, CS: HEX [BX]
Eh MOV AH, 0
INT 10 h
POP AX
AND AL, 0 fh
XOR BH, BH
MOV BL, AL
MOV AL, CS: HEX [BX]
Eh MOV AH, 0
INT 10 h
MOV AX, 0 e08h
INT 10 h
MOV AX, 0 e08h
INT 10 h
POP AX
RET
ShowCode ENDP
;
Music PROC NEAR
XOR AH, AH
CMP AL, _AL
Developed $NEW
JMP Loc_84
$NEW: MOV _AL, AL
The TEST of AL, 80 h
JNZ $Up
CALL KeyPush
MOV BX, AX
MOV KeyDownTbl [BX], - 1
;
$Down: SHL AX, 1
MOV BX, AX
MOV AX, OFFSET CS: ToneTbl
The ADD BX, AX
CX, MOV OFFSET CS: ToneTbl
CMP BX, CX
JGE Loc_79
Loc_78:
MOV BX, TblLen - 2
The ADD BX, AX
JMP Loc_80
Loc_79:
CX, MOV TblLen - 4
The ADD CX, AX
CMP BX, CX
JG Loc_78
Loc_80:
MOV AL, 0 b6h
The OUT 43 h, AL; Port h 43, 8253 WRT timr mode
MOV AX, 2870 h
MOV DX, 12 h
DIV WORD PTR CS: [BX]
The OUT 42 h, AL; The port 42 h, 8253 timer 2 SPKR
MOV AL, AH
The OUT 42 h, AL; The port 42 h, 8253 timer 2 SPKR
IN AL, 61 h; Port 61 h, 8255 port B, read
The OR AL, 3
OUT of 61 h, AL; The port 61 h, 8255 B - SPKR, etc
JMP Loc_84
;
$Up: the AND AL, 7 fh
MOV BX, AX
MOV KeyDownTbl [BX], 0
Loc_81: CALL KeyPop
CMP SI, OFFSET KeyStack - 1
JE $Off
MOV BX, AX
CMP KeyDownTbl [BX], 0
JE Loc_81
CALL KeyPush
JMP $Down
$Off: INC KeySP
IN AL, 61 h; Port 61 h, 8255 port B, read
AND AL, 0 FCH
OUT of 61 h, AL; The port 61 h, 8255 B - SPKR, etc
Loc_84:
CX, MOV 8
LocLoop_85:
LOOP LocLoop_85
RET
;
ToneTbl DB 42 h, 0, 45 h, 0, 4 ah, 0
53 h, DB 4 eh, 0, 0, 57 h, 0
The DB 5 dh, 0, 62 h, 0, 68 h, 0
6 DB eh, 0, 75 h, 0, 7 ch, 0
The DB 83 h, 0, 8 bh, 0, 93 h, 0
DB 9 eh, 0, 0 a5h, 0, 0 afh, 0
DB b9h 0, 0, 0 c4h, 0, 0 d0h, 0
DB DCH 0, 0, 0 e9h, 0, 0 f7h, 0
The DB 6, 1, 16 h, 1, 26 h, 1
The DB 38 h, 1, 4 ah, 1, 5 eh, 1
The DB 73 h, 1, 88 h, 1, 9 fh, 1
DB b8h 0, 1, 0 d2h, 1, 0 eeh, 1
Bh DB 0, 2, 2 ah, 2, 4 bh, 2
6 DB eh, 2, 93 h, 2, 0 bah, 2
DB 0 e4h, 2, and 10 h, 3, 3, eh, 3
The DB 70 h, 3, 0 a5h, 3, 0 DCH, 3
The DB 18 h, 4, 56 h, 4, 98 h, 4
DB f0h 0, 4, and 5, 76 h, 5 h
DB cah 0, 5, 22 h, 6, 80 h, 6
DB e3h 0, 6, 4 bh, 7, 7
0 bah,TblLen EQU $- ToneTbl
KeyDownTbl DB 80 h DUP (0)
KeyStack DB 100 DUP (?)
KeySP DW KeyStack
_AL DB 0
Music ENDP
;
KeyPush PROC
MOV SI, KeySP
MOV BYTE PTR [SI], AL
INC SI
MOV KeySP, SI
RET
KeyPush ENDP
KeyPop PROC
MOV SI, KeySP
DEC SI
MOV AL, BYTE PTR [SI]
MOV KeySP, SI
RET
KeyPop ENDP
;
;
START the PROC
PUSH CS
POP the DS
MOV AX, 3509 h
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull