;; Emacs Mode Selection Info: -*-mode: ASM; coding: iso-latin-1-dos;-*- * ;; ******************************************************************************************** ;; File Name: speaker.inc ;; Auther: John L. Weinrich ;; Date: 01/31/03 ;; Useage 4004 TIC-TAC-TOE Game ;; Description: ;; ;; This file is an include file containing speaker control routines. ;; ;; See "4004 FPGA Design" and "4004 Software Design " documents for more detail information. ;; ;; Registers used: SRC_P, SCRATCH_0_L, SCRATCH_0_H, SCRATCH_0_P, SCRATCH_1_L, SCRATCH_1_H, ;; SCRATCH_1_P, ; ;; Memory used: SPEAKER_LEVEL_RAM ;; Entrance parameters: None. ;; Exit parameters: Accumulator, success, failure ;; Labels used: Beep, LoopBeep, InitSpeaker, Pitch2232HZ, Pitch1116HZ, Pitch496HZ, ;; Pitch406HZ, SetPitch, Level1, Level2, Level3, Level4, Level5, Level6, Level7, ;; Level8, Level9, Level10, Level11, Level12, Level13, Level14, Level15, SetLevel ;; Routines used: None. ;; ******************************************************************************************** ;; ******************************************************************************************** ;; Beep speaker to acknowledge key press ;; ;; Turn speaker on Beep ldm RAM_BANK_0 ; Select RAM bank 0 dcl ; Send out RAM bank selection fim SRC_P,SPEAKER_LEVEL_RAM ; Select speaker level charactor src SRC_P ; Tell RAM of selection clb ; Make sure accumulator is clear rdm ; Get speaker level from RAM fim SRC_P,SPEAKER_LEVEL_PORT ; Select speaker level port src SRC_P ; Send out speaker level port selection wmp ; Write out selection ;; Wait for tone to be heard ;; Do the wait thing fim SCRATCH_0_P,0 ; Preset wait counter #1 fim SCRATCH_1_P,0 ; Preset wait counter #2 LoopBeep isz SCRATCH_0_H,LoopBeep ; Loop to waste time isz SCRATCH_0_L,LoopBeep ; loop again isz SCRATCH_1_H,LoopBeep ; And again ;; Turn speaker off fim SRC_P,SPEAKER_LEVEL_PORT ; Select speaker level port src SRC_P ; Send out speaker level port selection ldm SPEAKER_LEVEL_OFF ; Get speaker level wmp ; Write out selection bbl REPORT_SUCCESS ; All done, return ;; ******************************************************************************************** ;; This subroutine initializes the speaker ;; InitSpeaker fim SRC_P,SPEAKER_PITCH_PORT ; Get speaker pitch port src SRC_P ; Send out speaker pitch port selection ldm SPEAKER_PITCH_558HZ ; Get mid tone value wmp ; Write out selection fim SRC_P,SPEAKER_LEVEL_PORT ; Get speaker level port src SRC_P ; Send out speaker level port selection ldm SPEAKER_LEVEL_OFF ; Get speaker level value wmp ; Write out selection bbl REPORT_SUCCESS ; All done, return ;; ******************************************************************************************** ;; This subroutine sets the speaker tone. ;; Pitch2232HZ ldm SPEAKER_PITCH_2232HZ ; Get mid tone value jun SetPitch ; Go set the pitch Pitch1116HZ ldm SPEAKER_PITCH_1116HZ ; Get mid tone value jun SetPitch ; Go set the pitch Pitch496HZ ldm SPEAKER_PITCH_496HZ ; Get mid tone value jun SetPitch ; Go set the pitch Pitch406HZ ldm SPEAKER_PITCH_406HZ ; Get mid tone value jun SetPitch ; Go set the pitch SetPitch fim SRC_P,SPEAKER_PITCH_PORT ; Get speaker pitch port src SRC_P ; Send out speaker pitch port selection wmp ; Write out selection bbl REPORT_SUCCESS ; All done, return ;; ******************************************************************************************** ;; This subroutine sets the speaker level. ;; Level1 ldm SPEAKER_LEVEL_1 ; Get level value jun SetLevel ; Go set the pitch Level2 ldm SPEAKER_LEVEL_2 ; Get level value jun SetLevel ; Go set the pitch Level3 ldm SPEAKER_LEVEL_3 ; Get level value jun SetLevel ; Go set the pitch Level4 ldm SPEAKER_LEVEL_4 ; Get level value jun SetLevel ; Go set the pitch Level5 ldm SPEAKER_LEVEL_5 ; Get level value jun SetLevel ; Go set the pitch Level6 ldm SPEAKER_LEVEL_6 ; Get level value jun SetLevel ; Go set the pitch Level7 ldm SPEAKER_LEVEL_7 ; Get level value jun SetLevel ; Go set the pitch Level8 ldm SPEAKER_LEVEL_8 ; Get level value jun SetLevel ; Go set the pitch Level9 ldm SPEAKER_LEVEL_9 ; Get level value jun SetLevel ; Go set the pitch Level10 ldm SPEAKER_LEVEL_10 ; Get level value jun SetLevel ; Go set the pitch Level11 ldm SPEAKER_LEVEL_11 ; Get level value jun SetLevel ; Go set the pitch Level12 ldm SPEAKER_LEVEL_12 ; Get level value jun SetLevel ; Go set the pitch Level13 ldm SPEAKER_LEVEL_13 ; Get level value jun SetLevel ; Go set the pitch Level14 ldm SPEAKER_LEVEL_14 ; Get level value jun SetLevel ; Go set the pitch Level15 ldm SPEAKER_LEVEL_15 ; Get level value jun SetLevel ; Go set the pitch SetLevel xch SCRATCH_0_L ; Save level value ldm RAM_BANK_0 ; Select RAM bank 0 dcl ; Send out RAM bank selection fim SRC_P,SPEAKER_LEVEL_RAM ; Select speaker level charactor src SRC_P ; Tell RAM of selection xch SCRATCH_0_L ; Get level value wrm ; Write level value to RAM bbl REPORT_SUCCESS ; All done, return