====== NMI Sample player ====== Coded using the CA65 assembler. use like this: call NMIDIGI_Init once for init, then call NMIDIGI_Play with a pointer (x=hi,y=lo) to a table with parameters (data start lo/hi, data end lo/hi, samplerate lo/hi). NMIDIGI_Off temporarily disables the player, NMIDIGI_On enables it again. the various compile-time options should be self-explaining (i hope) :) ;------------------------------------------------------------------------- ; NMI Sample player (w) Groepaz/Hitmen ;------------------------------------------------------------------------- .export NMIDIGI_Init .export NMIDIGI_On .export NMIDIGI_Off .export NMIDIGI_Play .export NMIDIGION .export NMIDIGIOFF withsidplayer=0 .if(withsidplayer=1) sidplayervol=D418HLP .endif ;0: high nibble first 1: low nibble first firstnibble=1 ;1: no nibbles nonibbles=1 NMIDIGI_Init: jsr NMIDIGI_Off lda #$00 ldx #$00 @l: sta __SID__,x inx bne @l lda #$00 sta __SID__+$05 ; voice 1 ad lda #$f0 sta __SID__+$06 ; sr lda #$01 sta __SID__+$04 ; ctrl lda #$00 sta __SID__+$0c ; voice 2 ad lda #$f0 sta __SID__+$0d ; sr lda #$01 sta __SID__+$0b ; ctrl lda #$00 sta __SID__+$13 ; voice 3 ad lda #$f0 sta __SID__+$14 ; sr lda #$01 sta __SID__+$12 ; ctrl lda #$00 sta __SID__+$15 ; filter lo lda #$10 sta __SID__+$16 ; filter hi lda #%11110111 sta __SID__+$17 ; filter voices+reso rts NMIDIGI_On: LDA #>NMIDIGION STA $FFFB LDA #NMIDIGIOFF STA $FFFB LDA # ---------------- (Edit: Suggestion from Algorithm) the digiboost should be something along the lines of.. lda #$ff sta $d406 sta $d406+7 sta $d496+14 lda #$49 sta $d404 sta $d404+7 sta $d404+14 and the nmi frequency needs to be set. eg lda #$3c sta $dd04 lda #$00 sta $dd05 ---------------- (Edit enthusi) If you are in real need for cycles and have some RAM left you can replace the LSRs with: tay lda freq_table,y and set up a table via ldx #0 loop2 ldy #16 value lda #0 loop sta freq_table,x inx dey bne loop cpx #$00 beq end inc value+1 jmp loop2 end rts