📄 melody.asm
字号:
;; ROR A
;; ROR A
;; ROR A
;; AND #%00000111
;; ORA R_QIndexCh2
;; BCC L_NotAdpcmEndCh2
;; BNE L_NotAdpcmEndCh2
;; BCS L_EndSpeechCh2
;;L_NeedNewSampleCh2:
;; %ReadSpeechDataCh2
;; ROR A
;; STA R_EncodedCh2
;;L_ProcessAdpcmCh2:
;; AND #%00000111
;; ORA R_QIndexCh2
;; BNE L_NotAdpcmEndCh2
;; BCS L_EndSpeechCh2
;;L_NotAdpcmEndCh2:
;; TAX
;; LDA T_NextStep,X
;; STA R_QIndexCh2
;; LDA T_SlopeTable,X
;; BCC L_AdpcmPlusCh2
;; EOR #$FF
;; ADC R_DacCh2
;; BCS L_AdpcmExitCh2
;; LDA #0 ;Test
;; BCC L_AdpcmExitCh2
;;L_AdpcmPlusCh2:
;; ADC R_DacCh2
;; BCC L_AdpcmExitCh2
;; LDA #$FF ;Test
;;L_AdpcmExitCh2:
;; STA R_DacCh2 ;store decoded data
;; STA P_DacCh2
;; JMP L_ExitCh2
;; .ENDIF
;;;/**************************************************************************/
;;;/* PlaySpeech: A wordindex, X frequency index */
;;;/*****************************************************************************/
;;;/* Stack used : 4 */
;;;/**************************************************************************/
;;F_PlaySpeechCh1:
;; PHA
;;L_NormalSpeechWordCh1:
;; SEI
;; LDA R_IntFlags
;; AND #.NOT.D_TimerCh1
;; STA R_IntFlags
;; STA P_Ints
;; CLI
;; LDA T_SpeechFreqTable,y ;set up frequency
;; STA P_TimerCh0L
;; LDA T_SpeechFreqTable+1,y
;; STA P_TimerCh0H
;; PLA
;; tay
;; SEI
;; %SetSPeechPointCh1
;; CLI
;; LDX #D_RampDownValue
;; STX R_DacCh1
;; STX P_DacCh1
;; SEI
;; LDA R_StatusCh1
;; AND #.NOT.(D_ChPlayTone+D_MuteFlag+D_NibbleFlag)
;; ORA #D_ChActive+D_ChPlaySpeech
;;L_SetUpPlayCh1:
;; STA R_StatusCh1
;; CLI
;; LDA #0
;; STA R_QIndexCh1
;; %SetPWMSpeechCh1On
;; %SetTimerStart
;; SEI
;; LDA R_IntFlags
;; ORA #D_TimerCh1
;; STA R_IntFlags ;;EDIT FOR SPL
;; STA P_Ints
;; CLI
;; RTS
;;;/*****************************************************************************/
;;;/* Stack used : 4 */
;;;/**************************************************************************/
;;F_PlaySpeechCh2:
;; PHA
;; SEI
;; LDA R_IntFlags
;; AND #.NOT.D_TimerCh2
;; STA R_IntFlags
;; STA P_Ints
;; CLI
;; LDA T_SpeechFreqTable,y ;set up frequency
;; STA P_TimerCh1L
;; LDA T_SpeechFreqTable+1,y
;; STA P_TimerCh1H
;; PLA
;; tay
;; SEI
;; %SetSPeechPointCh2
;; CLI
;; LDX #D_RampDownValue
;; STX R_DacCh2
;; STX P_DacCh2
;; SEI
;; LDA R_StatusCh2
;; AND #.NOT.(D_ChPlayTone+D_MuteFlag)
;; ORA #D_ChActive+D_ChPlaySpeech
;;L_SetUpPlayCh2:
;; STA R_StatusCh2
;; CLI
;; LDA #0
;; STA R_QIndexCh1
;; %SetPWMSpeechCh2On
;; %SetTimerStart
;; SEI
;; LDA R_IntFlags
;; ORA #D_TimerCh2
;; STA R_IntFlags
;; STA P_Ints
;; CLI
;; RTS
;;;/**************************************************************************/
;;;/* Play Mute: X,A Mute length */
;;;/**************************************************************************/
;;;/* Stack used : 4 */
;;;/**************************************************************************/
;;
;;F_PlayMuteCh1:
;; ;/* Disable channel interrupt */
;; TAY
;;
;; SEI
;; LDA R_IntFlags
;; AND #.NOT.D_TimerCh1
;; STA R_IntFlags
;; STA P_Ints
;; CLI
;; STY R_DataDPTRCh1
;; STX R_DataDPTRCh1+1
;; LDA T_RampFreqTable
;; STA P_TimerCh0L
;; LDA T_RampFreqTable+1
;; STA P_TimerCh0H
;; LDA #80H
;; STA R_DataDPTRCh1+2
;;L_MuteNotNeedRampDownFromToneCh1:
;; SEI
;; LDA R_StatusCh1
;; AND #.NOT.D_ChPlayTone
;; ORA #D_ChActive+D_ChPlaySpeech+D_MuteFlag
;; JMP L_SetUpPlayCh1
;;;/*****************************************************************************/
;;;/* Stack used : 4 */
;;;/**************************************************************************/
;;F_PlayMuteCh2:
;; TAY
;; SEI
;; LDA R_IntFlags
;; AND #.NOT.D_TimerCh2
;; STA R_IntFlags
;; STA P_Ints
;; CLI
;;
;; STY R_DataDPTRCh2
;; STX R_DataDPTRCh2+1
;;
;;
;; LDA T_RampFreqTable
;; STA P_TimerCh1L
;; LDA T_RampFreqTable+1
;; STA P_TimerCh1H
;;
;; LDX #80H
;; STX R_DataDPTRCh2+2
;;L_MuteNotNeedRampDownFromToneCh2:
;; SEI
;; LDA R_StatusCh2
;; AND #.NOT.D_ChPlayTone
;; ORA #D_ChActive+D_ChPlaySpeech+D_MuteFlag
;; JMP L_SetUpPlayCh2
;/*****************************************************************************/
;/* Stack used : 4 */
;/**************************************************************************/
;/*********************************************************************/
;/* Stack used: 5 */
;/*********************************************************************/
;/**************************************************************************/
F_StopCh1:
LDA #D_RampDownValue
STA P_DacCh1
LDA R_StatusCh1
AND #.NOT.D_ChPlayTone
STA R_StatusCh1
RTS
F_StopCh2:
LDA #D_RampDownValue
STA P_DacCh2
LDA R_StatusCh2
AND #.NOT.D_ChPlayTone
STA R_StatusCh2
RTS
F_StopPlay:
SEI
JSR F_StopPlayInIRQ
CLI
RTS
F_StopPlayInIRQ:
LDA R_IntFlags
AND #.NOT.(D_TimerCh2+D_TimerCh1)
STA R_IntFlags
STA P_Ints
LDA R_MelodyStatus
AND #.NOT.D_MelodyEnable
STA R_MelodyStatus
LDA #0
STA R_StatusCh1
STA R_StatusCh2
%SetPWMCh1Off
%SetPWMCh2Off
%SetTimerStop
LDA #D_RampDownValue
STA P_DacCh1
STA P_DacCh2
RTS
T_RampFreqTable:
%LoadSpeechFreq 10000
;/**************************************************************************/
T_ToneFreqTable:
%LoadOctaveToneFreq 013081/100 ;index 00 -- 22
%LoadOctaveToneFreq 026162/100 ;index 24 -- 46
%LoadOctaveToneFreq 052324/100 ;index 48 -- 70
%LoadOctaveToneFreq 104648/100 ;index 72 -- 94
%LoadOctaveToneFreq 209296/100 ;index 96 -- 118
%LoadOctaveToneFreq 418592/100 ;index 120 -- 142
%LoadToneFreq 1000 ;index 144
;/**************************************************************************/
;/**************************************************************************/
T_MultiBy12Table:
DB 0, 12, 24, 36, 48, 60, 72, 84
;/**************************************************************************/
T_TempoTable:
%LoadTempo 30 ;tempo = 30
%LoadTempo 40 ;tempo = 40
%LoadTempo 50 ;tempo = 50
%LoadTempo 60 ;tempo = 60
%LoadTempo 70 ;tempo = 70
%LoadTempo 80 ;tempo = 80
%LoadTempo 90 ;tempo = 90
%LoadTempo 100 ;tempo = 100
%LoadTempo 110 ;tempo = 110
%LoadTempo 120 ;tempo = 120
%LoadTempo 130 ;tempo = 130
%LoadTempo 140 ;tempo = 140
%LoadTempo 150 ;tempo = 150
%LoadTempo 160 ;tempo = 160
%LoadTempo 170 ;tempo = 170
%LoadTempo 180 ;tempo = 180
%LoadTempo 190 ;tempo = 190
%LoadTempo 200 ;tempo = 200
%LoadTempo 210 ;tempo = 210
%LoadTempo 220 ;tempo = 220
%LoadTempo 230 ;tempo = 230
%LoadTempo 240 ;tempo = 240
%LoadTempo 250 ;tempo = 250
%LoadTempo 260 ;tempo = 260
%LoadTempo 270 ;tempo = 270
%LoadTempo 280 ;tempo = 280
%LoadTempo 290 ;tempo = 290
%LoadTempo 300 ;tempo = 300
%LoadTempo 310 ;tempo = 310
%LoadTempo 320 ;tempo = 320
%LoadTempo 330 ;tempo = 330
%LoadTempo 340 ;tempo = 340
;/**************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -