;13.音符显示子程序
;---------YFDSUP(13)--------
YFDSUP: MOV A,STATU
JNZ YFDRET
JB SECHSTOF,YFDRET
JNB CUYFD,YFSLED
XZFCLD: MOV DISNUM0,#20H
MOV DISNUM1,#20H
SJMP YFDSPLAY
YFSLED: MOV A,R6
JZ XZFCLD
ANL A,#0FH
PUSH DPL
PUSH DPH
MOV DPTR,#T_YFDCOD
MOVC A,@A+DPTR
MOV DISNUM0,A
POP DPH
POP DPL
MOV A,R6
SWAP A
ANL A,#0FH
MOV DISNUM1,A
YFDSPLAY: LCALL DISPLAY
YFDRET: RET
T_YFDCOD: DB 20H ;--
DB 01H ; 1
DB 02H ; 2
DB 03H ; 3
DB 04H ; 4
DB 05H ; 5
DB 06H ; 6
DB 07H ; 7
DB 11H ;#1
DB 12H ;#2
DB 14H ;#4
DB 15H ;#5
DB 16H ;#6
;14.唱音符子程序
;---------PLAY(14)----------
PLAY: MOV A,R6
JZ PCOSPECL
PUSH DPL
PUSH DPH
MOV DPTR,#T_SD
ANL A,#0FH
MOVC A,@A+DPTR
XCH A,R6
SWAP A
ANL A,#0FH
MOV B,#12
MUL AB
ADD A,R6
ADD A,R2
RL A
MOV R6,A
MOV DPTR,#T_RAN
MOVC A,@A+DPTR
MOV TH0,A
MOV R5,A
MOV A,R6
INC A
MOVC A,@A+DPTR
MOV TL0,A
MOV R4,A
POP DPH
POP DPL
SETB TR0
PCOSPECL: LCALL COSPECL
PJPWAIT: MOV JPCLK,#00H
PDELAY: LCALL KCXCL
JB NEXTSF,PRET
MOV A,JPCLK
CJNE A,01H,PNEXT
PNEXT: JC PDELAY
DJNZ R7,PJPWAIT
PRET: CLR TR0
RET
;---------TABSD-------------
T_SD: DB 01h ;useless
DB 01H
DB 03H
DB 05H
DB 06H
DB 08H
DB 0AH
DB 0CH
DB 02H
DB 04H
DB 07H
DB 09H
DB 0bH
;---------TABRAN------------
T_RAN: DW 0F111H ;useless
dw 0f111h ; area 0
dw 0f1e8h
dw 0f2b2h
dw 0f373h
dw 0f426h
dw 0f4eeh
dw 0f571h
dw 0f609h
dw 0f699h
dw 0f71fh
dw 0f79fh
dw 0f817h
dw 0f889h ; area 1
dw 0f8f4h
dw 0f95ah
dw 0f9b9h
dw 0fa13h
dw 0fa68h
dw 0fab9h
dw 0fb04h
dw 0fb4ch
dw 0fb90h
dw 0fbcfh
dw 0fc0ch
dw 0fc45h ;area 2
dw 0fc7ah
dw 0fcadh
dw 0fcdch
dw 0fd0ah
dw 0fd34h
dw 0fd5ch
dw 0fd82h
dw 0fda6h
dw 0fdc8h
dw 0fde8h
dw 0fe06h
dw 0fe22h ; area 3
dw 0fe3dh
dw 0fe56h
dw 0fe6eh
dw 0fe85h
dw 0fe9ah
dw 0feaeh
dw 0fec1h
dw 0fed3h
dw 0fee3h
dw 0fef4h
dw 0ff02h
dw 0ff11h ;area 4
dw 0ff1fh
dw 0ff2bh
dw 0ff37h
dw 0ff42h
dw 0ff4dh
dw 0ff57h
dw 0ff60h
dw 0ff6ah
dw 0ff72h
dw 0ff7ah
dw 0ff81h
dw 0ff89h ; 5
;15.共速处理
;---------COSPECL(15)-------
COSPECL: MOV R1,03H
MOV A,COSPEEDN
JZ COSPRET
PUSH COSPEEDN
MOV A,R1
COSPEGON: MOV B,#08H
MUL AB
CLR C
SUBB A,R1
JNC COSPNEXT
DEC B
COSPNEXT: MOV R6,#03H
DIV8: CLR C
XCH A,B
RRC A
XCH A,B
RRC A
DJNZ R6,DIV8
MOV R1,A
DJNZ COSPEEDN,COSPEGON
POP COSPEEDN
MOV A,R1
JNZ COSPRET
MOV R1,#01H
COSPRET: RET
;16.键盘查询处理
;---------KCXCL(16)---------
KCXCL: LCALL KSET
LCALL KALT0
LCALL KALT1
JNB KSETF,KNEXT0
LCALL KSETCL
KSETSTC: MOV SETST0,#00H
MOV SETST1,#00H
SETB KBDISF
SJMP KDIS
KNEXT0: JNB KALT0F,KNEXT1
LCALL KALT0CL
SJMP KSETSTC
KNEXT1: JNB KALT1F,KDIS
LCALL KALT1CL
SJMP KSETSTC
KDIS: MOV A,STATU
JNZ KSSNSD
JNB SECHSTOF,KRET
KSSNSD: JNB KBDISF,KRET
CLR KBDISF
LCALL DISPLAY
KRET: RET
;17.KSET键是否按下查询
;---------KSET(17)----------
KSET: SETB SET
JB SET,CSETRET
MOV GENCLK,#00H
SETLOP: MOV A,GENCLK
CJNE A,#02,SETLOP
SETB SET
JB SET,CSETRET
CLR TR0
SETWAIT: SETB SET
JNB SET,SETWAIT
MOV GENCLK,#00H
SETLOP1: MOV A,GENCLK
CJNE A,#02,SETLOP1
SETB TR0
SETB KSETF
RET
CSETRET: CLR KSETF
RET
;18.KALT0键是否按下查询
;---------KALT0(18)---------
KALT0: SETB ALT0
JB ALT0,CALT0RET
MOV GENCLK,#00H
ALT0LOP: MOV A,GENCLK
CJNE A,#02,ALT0LOP
SETB ALT0
JB ALT0,CALT0RET
CLR TR0
ALT0WAIT: SETB ALT0
JNB ALT0,ALT0WAIT
MOV GENCLK,#00H
ALT0LOP1: MOV A,GENCLK
CJNE A,#02,ALT0LOP1
SETB TR0
SETB KALT0F
RET
CALT0RET: CLR KALT0F
RET
;19.KALT1键是否按下查询
;---------KALT1(19)---------
KALT1: SETB ALT1
JB ALT1,CALT1RET
MOV GENCLK,#00H
ALT1LOP: MOV A,GENCLK
CJNE A,#02,ALT1LOP
SETB ALT1
JB ALT1,CALT1RET
CLR TR0
ALT1WAIT: SETB ALT1
JNB ALT1,ALT1WAIT
MOV GENCLK,#00H
ALT1LOP1: MOV A,GENCLK
CJNE A,#02,ALT1LOP1
SETB TR0
SETB KALT1F
RET
CALT1RET: CLR KALT1F
RET
;20.SET键处理
;---------KSETCL(20)--------
KSETCL: INC STATU
MOV A,STATU
CJNE A,#07H,STATUDIS
MOV STATU,#00H
STATUDIS: MOV DISNUM0,#23H
MOV DISNUM1,STATU
RET
;21.KALT0键处理
;---------KALT0CL(21)-------
KALT0CL: MOV A,STATU
JNZ CASEB1
KA0S0G INC DPTR
INC DPTR
LCALL RYFSUP
MOV A,R7
JNZ EQUFF
MOV DPTR,#T_SONGS
SJMP KA0NEXT
EQUFF: INC A
JNZ KA0S0GO
KA0NEXT: LCALL RYFSUP
MOV CSN,R6
LCALL CSNSDISN
MOV A,DPL
CLR C
SUBB A,#02H
JNC KA0NEXT1
DEC DPH
KA0NEXT1: MOV DPL,A
CLR REP0F
CLR REP1F
CLR REP2F
CLR REP3F
SETB NEXTSF
SETB SECHSTOF
RET
CASEB1: CJNE A,#01H,CASEB2
INC LDYDSR
MOV A,LDYDSR
CJNE A,#04H,LDYDSL4
MOV LDYDSR,#00H
LDYDSL4: MOV DISNUM0,LDYDSR
MOV DISNUM1,#26H
RET
HCOSPEEDN EQU 12H
CASEB2: CJNE A,#02H,CASEB3
MOV A,COSPEEDN
CJNE A,#HCOSPEEDN,KA0NEXT4
KA0NEXT4: JNC KA0NEXT5
INC COSPEEDN
KA0NEXT5: MOV SPENR,COSPEEDN
LCALL SPENSDISN
RET
CASEB3: CJNE A,#03H,CASEB4
CLR SPEEDF
LCALL SPEEDCL
RET
CASEB4: CJNE A,#04H,CASEB5
CLR TONEF
LCALL TONECL
RET
CASEB5: CJNE A,#05H,CASEB6
CPL LOCF
JNB LOCF,KA0NEXT2
MOV DISNUM0,#24H
SJMP KA0NEXT3
KA0NEXT2: MOV DISNUM0,#25H
KA0NEXT3: MOV DISNUM1,#26H
RET
CASEB6: CJNE A,#06H,KA0RET
CPL CUYFD
JNB CUYFD,KA0NEXT6
MOV DISNUM0,#24H
SJMP KA0NEXT7
KA0NEXT6: MOV DISNUM0,#25H
KA0NEXT7: MOV DISNUM1,#28H
KA0RET: RET
;22.速度数送显示寄存器
;---------SPENSDISN(22)----
SPENSDISN:MOV A,SPENR
ANL A,#0FH
MOV DISNUM0,A
MOV A,SPENR
SWAP A
ANL A,#0FH
MOV DISNUM1,A
RET
;23.速度处理
;---------SPEEDCL(23)------
HSPEED EQU 02H;
LSPEED EQU 50H;
SPEEDCL: JB SPEEDF,DNSPEED
CJNE R3,#HSPEED,SCLNEXT
SCLNEXT: JC SCLNEXT1
DEC R3
SJMP SCLNEXT1
DNSPEED:
CJNE R3,#LSPEED,SCLNEXT2
SCLNEXT2: JNC SCLNEXT1
INC R3
SCLNEXT1: LCALL CSBESTOJG
JNB CSBESTOF,SCLNEXT3
INC R0
INC R0
MOV @R0,03H
SCLNEXT3: LCALL COSPECL
MOV SPENR,R1
LCALL SPENSDISN
RET
;24.音调处理
;---------TONECL(24)---------
;LTONE EQU 00 ;C
HTONE EQU 11 ;B
TONECL: JB TONEF,DNTONE
CJNE R2,#HTONE,TCLNEXT0
TCLNEXT0: JNC TCLNEXT
INC R2
SJMP TCLNEXT
DNTONE: MOV A,R2
JZ TCLNEXT
DEC R2
TCLNEXT: LCALL CSBESTOJG
JNB CSBESTOF,TCLNEXT1
INC R0
MOV @R0,02H
TCLNEXT1: PUSH DPL
PUSH DPH
MOV DPTR,#T_TONDISC
MOV A,R2
RL A
MOVC A,@A+DPTR
MOV DISNUM1,A
MOV A,R2
RL A
INC A
MOVC A,@A+DPTR
MOV DISNUM0,A
POP DPH
POP DPL
RET
T_TONDISC W 200CH ; C
DW 210CH ;#C
DW 200DH ; D
DW 210DH ;#D
DW 200EH ; E
DW 200FH ; F
DW 210FH ;#F
DW 2022H ; G
DW 2122H ;#G
DW 200AH ; A
DW 210AH ;#A
DW 200BH ; B
;25.KALT1键处理
;---------KALT1CL(25)--------
KALT1CL: MOV A,STATU
JNZ CASE1
LCALL CSBESTOJG
JNB CSBESTOF,KA1NEXT
MOV @R0,#00H
DEC BUFF0
SJMP KA1NEXT2
KA1NEXT: CJNE R0,#7EH,KA1NEXT1
KA1NEXT1: JNC KA1NEXT2
MOV @R0,CSN
INC R0
MOV @R0,02H
INC R0
MOV @R0,03H
INC BUFF0
KA1NEXT2: LCALL CSNSDISN
SETB SECHSTOF
RET
CASE1: CJNE A,#01H,CASE2
INC RDYDSR
MOV A,RDYDSR
CJNE A,#04H,RDYDSL4
MOV RDYDSR,#00H
RDYDSL4: MOV DISNUM0,RDYDSR
MOV DISNUM1,#27H
RET
CASE2: CJNE A,#02H,CASE3
MOV A,COSPEEDN
JZ KA1NEXT5
DEC COSPEEDN
KA1NEXT5: MOV SPENR,COSPEEDN
LCALL SPENSDISN
RET
CASE3: CJNE A,#03H,CASE4
SETB SPEEDF
LCALL SPEEDCL
RET
CASE4: CJNE A,#04H,CASE5
SETB TONEF
LCALL TONECL
RET
CASE5: CJNE A,#05H,CASE6
CPL ROCF
JNB ROCF,KA1NEXT3
MOV DISNUM0,#24H
SJMP KA1NEXT4
KA1NEXT3: MOV DISNUM0,#25H
KA1NEXT4: MOV DISNUM1,#27H
RET
CASE6: CJNE A,#06H,KA1RET
MOV DISNUM0,#23H
MOV DISNUM1,#06H
KA1RET: RET
;========= 乐曲表============
;---------SONGS--------------
T_SONGS: 乐曲表表首
dw 01ffh,;song1:xiao la ba...
dw 0b05h,
dw 2504h,
dw 2604h,
dw 2506h,
dw 0002h,
dw 2504h,
dw 2604h,
dw 2506h,
dw 0002h,
dw 2504h,
dw 2604h,
dw 2504h,
dw 2304h,
dw 2204h,
dw 2104h,
dw 2206h,
DW 16FFH;SONG16 iang Zhi Lao Hu
DW 0715H
DW 0FF21H ;REP21
DW 0FF01H ;REP01
DW 2102H
DW 2202H
DW 2302H
DW 2102H
DW 0FF02H ;REP02
DW 0FF03H ;REP03
DW 2302H
DW 2402H
DW 2504H
DW 2302H
DW 2402H
DW 2504H
DW 0FF11H ;REP11
DW 2501H
DW 2601H
DW 2501H
DW 2401H
DW 2302H
DW 2102H
DW 0FF12H ;REP12
DW 0FF13H ;REP13
DW 2202H
DW 1502H
DW 2104H
DW 2202H
DW 1502H
DW 2104H
DW 0FF22H ;REP22
DW 0FF23H ;REP23
DW 0000H ;乐曲表表尾
END
;=========END================
|