; ; db_5b.s ; relative volume test for 5B expansion ; https://github.com/bbbradsmith/nes-audio-tests ; .include "swap.inc" NSF_STRINGS "db_5b test", "Brad Smith", "2018 nes-audio-tests" NSF_EXPANSION = %00100000 INES2_REGION = 0 ; NTSC only .export test_registers .export test_routines .export test_data .exportzp NSF_EXPANSION .exportzp INES2_REGION .segment "SWAP" test_registers: ; $20 ; not used test_routines: ; $40 .word init_5b .word reg INIT_5B = $40 ; arg ignored REG = $41 ; two byte arg: register, value test_data: .byte BUZZ, 50 .byte INIT_APU, 0 .byte INIT_5B, 0 .byte DELAY, 60 ; APU 440Hz square .byte $00, %10111111 ; square duty, constant, full volume .byte $02, 253 ; (253+1)*16 = 4064 cycle square = ~440.40Hz .byte $03, $F0 .byte DELAY, 120 .byte $00, %00110000 ; zero volume .byte DELAY, 60 ; 5B 440Hz square .byte REG, $0, <127 .byte REG, $1, >127 ; 127*2*16 = 4064 cycle square .byte REG, $8, $0C ; volume C .byte REG, $7, %00111110 ; enable .byte DELAY, 120 .byte REG, $7, %00111111 ; disable .byte DELAY, 60 .byte LOOP reg: tya tax ; X = register ldy #0 lda (read_ptr), Y tay ; Y = value inc read_ptr+0 bne :+ inc read_ptr+1 : stx $C000 sty $E000 rts init_5b: ldy #0 ldx #0 : ; 0 to all registers stx $C000 sty $E000 inx cpx #$10 bcc :- lda #$07 ; disable all noise/tone sta $C000 lda #%00111111 sta $E000 rts ; end of file