Write_SoundHW: .noduty2change ;************************************************* stz $0800 ;Choose channel 0 sta $0803 sta $0802 lda #$FF sta $0805 ;Set to left channel ora #$80 sta $0804 ;Write PCE Volume ;==================================================== lda #$01 sta $0800 ;Choose channel 1 and #$07 sta $0803 sta $0802 lda #$2F sta $0805 ;Set to right channel ora #$80 sta $0804 ;Write PCE Volume ;==================================================== lda #$02 sta $0800 ;Choose channel 2 sta $0802 sta $0803 lda #$AD sta $0805 ;Set to left channel ora #$80 sta $0804 ;Write PCE Volume ;==================================================== lda #$04 sta $0800 ;Choose channel 4 ;Noise! ora #$80 sta $0807 ;NOISE-ONLY REGISTER! lda #$C6 sta $0805 ;Set to right channel sta $0804 ;Write PCE Volume ;==================================================== rts ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ setup_sound: cly clx ;Square wave ; ldx #192 ;Triangle jsr setup_sound_regs ;0 ldy #1 clx ;Square wave ; ldx #192 ;Triangle jsr setup_sound_regs ;1 ldy #2 ldx #128 ;Triangle ; ldx #192 ;Triangle jsr setup_sound_regs ;2 ldy #3 clx jsr setup_sound_regs ;3 ldy #4 clx jsr setup_sound_regs ;4 ldy #5 clx jsr setup_sound_regs ;5 rts setup_sound_regs: ;Inputs: Y-channel #, X-waveform sty $0800 ;Choose channel 0 lda #%01000000 ;reset the waveform write pointer sta $0804 lda #%00000000 sta $0804 cly load: lda wave_tables,x ; Load a sample in A sta $0806 ; Write the sample inx ; Increment the table index iny cpy #32 ; Have we reached the end? bne load ; If no continue stw #$0000,$0802 ;Write a word (frequency) lda #$FF sta $0805 ;Equal Balance. sta $0801 ;Master Volume lda #$00 eor #$00 ;We do this by ORing with the volume. sta $0804 rts ;----------------------------------------------- wave_tables: wave_square0: db 31,31,31,31,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 wave_square1: db 30,30,30,30,30,30,30,30,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 wave_square2: db 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 wave_square3: db 30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30 db 30,30,30,30,30,30,30,30,0,0,0,0,0,0,0,0 wave_triangle: db 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30 db 31,29,27,25,23,21,19,17,15,13,11,9,7,5,3,1 wave_sine: db 18,22,24,26,28,28,30,30 db 30,30,28,28,26,24,22,18 db 12,8,6,4,2,2,0,0 db 0,0,2,2,4,6,8,12 wave_saw: db 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 db 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31