@_DiskDoctor_, post #3
@asman, post #8
@asman, post #8
@asman, post #8
lea CUSTOM,a4 ;turn off move.w #DMAF_AUDIO,dmacon(a4) move.w #$FF,adkcon(a4) ;modulation off move.w #INTF_AUD0!INTF_AUD1!INTF_AUD2!INTF_AUD3,intena(a4) bsr.w SetAudio ;set audio1 (vol, per, len) ;start audio move.w #DMAF_SETCLR!DMAF_MASTER!DMAF_AUD0!DMAF_AUD1,dmacon(a4) .loop eor.w #1,d7 ;change buffer bsr.w ReadFrame ;read to hidden buffer bne.s .end bsr.w SetAudio ;set audio for hidden frame ;wait for end of actual audio move.w #INTF_AUD0!INTF_AUD1,intreq(a4) .wait move.w intreqr(a4),d0 and.w #INTF_AUD0!INTF_AUD1,d0 beq.s .wait btst #10,potinp(a4) ;check right mouse button beq.s PlayEnd ;wait for vbl move.w #INTF_VERTB,intreq(a4) .vbl move.w intreqr(a4),d0 and.w #INTF_VERTB,d0 beq.s .vbl bra.s .loop ;wait for end of last frame audio .end move.w #INTF_AUD0!INTF_AUD1,intreq(a4) .wait2 move.w intreqr(a4),d0 and.w #INTF_AUD0!INTF_AUD1,d0 beq.s .wait2 PlayEnd ;stop audio move.w #DMAF_AUDIO,dmacon(a4)
@cholok, post #13
;/////////////////////////////////////////////////// Statement PLAYSOUND{soundaddr.l , kanal.w , vol.w} SetValueForDMACON MOVE.l #%1000001000000000,d3 TST.b d1 : BEQ.b 'AUD0 CMP.b #1,d1 : BEQ.b 'AUD1 CMP.b #2,d1 : BEQ.b 'AUD2 CMP.b #3,d1 : BEQ.b 'AUD3 BRA 'DALEJ 'AUD0 ORI.b #%1,d3 BRA 'DALEJ 'AUD1 ORI.b #%10,d3 BRA 'DALEJ 'AUD2 ORI.b #%100,d3 BRA 'DALEJ 'AUD3 ORI.b #%1000,d3 'DALEJ ;NR KANALU LSL.b #4,d1 ;TYP DZWIEKU MOVE.l d0,a0 ;BAZA HARDWARE LEA $dff000,a6 ADDA.l d1,a6 ADDA.l #$A0,a6 MOVE.l (a0),(a6) ; _data.l AUDxLCN MOVE.w 6(a0),4(a6) ; _length.w AUDxLEN MOVE.w 4(a0),6(a6) ; _period.w AUDxPER MOVE.w d2,8(a6) ; volume.w AUDxVOL MOVE.w d3,$dff096 ; DMACON End Statement ;/////////////////////////////////////////////////// PLAYSOUND{Addr Sound(0) , 0 , 63} ; kanal 0 PLAYSOUND{Addr Sound(0) , 1 , 63} ; kanal 1
@tukinem, post #14
;/////////////////////////////////////////////////// Statement PLAYSOUND{soundaddr.l , kanal.w , vol.w} SetValueForDMACON MOVEQ #1,d3 TST.b d1 : BEQ.b 'DALEJ1 MOVEQ #2,d3 CMP.b #1,d1 : BEQ.b 'DALEJ MOVEQ #8,d3 CMP.b #2,d1 : BNE.b 'DALEJ MOVEQ #4,d3 'DALEJ ;NR KANALU LSL.b #4,d1 'DALEJ1 ;TYP DZWIEKU MOVE.l d0,a0 ;BAZA HARDWARE LEA $dff0A0,a6 ADDA.w d1,a6 ORI.w #%1000001000000000,d3 MOVE.l (a0),(a6) ; _data.l AUDxLCN MOVE.w 6(a0),4(a6) ; _length.w AUDxLEN MOVE.w 4(a0),6(a6) ; _period.w AUDxPER MOVE.w d2,8(a6) ; volume.w AUDxVOL MOVE.w d3,$dff096 ; DMACON End Statement ;/////////////////////////////////////////////////// PLAYSOUND{Addr Sound(0) , 0 , 63} ; kanal 0 PLAYSOUND{Addr Sound(0) , 1 , 63} ; kanal 1
@Don_Adan, post #12
To chyba Crazy Cars 1/2 lub Fire and Forget 1/2 to byla muzyka (sampel odgrywany z chipu).
O ile dobrze pamietam.
include hardware/custom.i ;----------------------------------------------------------------------------- XDEF _PlaySample ;a0 - address of sample (CHIP memory) ;d3 - length of sample ;a2 - address of empty sample _PlaySample: movem.l D0-A6,-(A7) lea $dff000,A5 ; load CustomBase lea $b0(a5),a1 ; channel moveq #2,D2 .StopDMA move.b vhposr(A5),d1 .WaitLine1 cmp.b vhposr(A5),d1 ; sync routine to start at linestart beq.s .WaitLine1 .WaitDMA1 cmp.b #$16,vhposr+1(A5) ; wait til after Audio DMA slots bcs.s .WaitDMA1 move.w #1,6(A1) move.w dmaconr(A5),d0 ; get active channels and.w d2,d0 move.w d0,d1 lsl.w #7,d0 move.w d0,intreq(A5) ; clear requests move.w d1,dmacon(A5) ; stop channels .WaitStop move.w intreqr(A5),d1 ; wait until all channels are stopped and.w d0,d1 cmp.w d0,d1 bne.s .WaitStop .Skip ; Here you must set the oneshot-parts of the samples you stopped before move.l A0,(A1) ;address of sample move.w d3,4(A1) ;lenght move.w #160,6(A1) ;11050 move.w #$40,8(A1) move.b vhposr(A5),d1 .WaitLine2 cmp.b vhposr(A5),d1 ; sync routine to start at linestart beq.s .WaitLine2 .WaitDMA2 cmp.b #$16,vhposr+1(A5) ; wait til after Audio DMA slots bcs.s .WaitDMA2 .StartDMA move.w dmaconr(A5),d0 ; get active channels not.w d0 and.w D2,D0 move.w d0,d1 or.w #$8000,d1 lsl.w #7,d0 move.w d0,intreq(A5) ; clear requests move.w d1,dmacon(A5) ; start channels .WaitStart move.w intreqr(A5),d1 ; wait until all channels are running and.w d0,d1 cmp.w d0,d1 bne.s .WaitStart move.b vhposr(A5),d1 .WaitLine3 cmp.b vhposr(A5),d1 ; sync routine to start at linestart beq.s .WaitLine3 .WaitDMA3 cmp.b #$16,vhposr+1(A5) ; wait til after Audio DMA slots bcs.s .WaitDMA3 move.l A2,(A1) move.w #1,4(A1) movem.l (A7)+,D0-A6 rts ;-----------------------------------------------------------------------------
@asman, post #8
struct Custom *custom = (void*)0xdff000; LONG audiosig = -1; void StartAudio( void ) { // tu trzeba jeszcze ac_ptr, u mnie były stałe custom->aud[0].ac_vol = ioregs.vol; custom->aud[1].ac_vol = ioregs.vol; custom->aud[0].ac_per = ioregs.period; custom->aud[1].ac_per = ioregs.period; custom->intreq = INTF_AUD1; custom->intena = INTF_SETCLR|INTF_AUD1; custom->dmacon = DMAF_SETCLR|DMAF_MASTER|DMAF_AUD0|DMAF_AUD1; } void AbortAudio( void ) { custom->dmacon = DMAF_AUD0|DMAF_AUD1; custom->intena = INTF_AUD1; custom->intreq = INTF_AUD1; } void __interrupt __saveds AudioServer( void ) { custom->intreq = INTF_AUD1; Signal( mytask, 1<<audiosig ); } struct Interrupt *oldaudiovec = NULL; struct Interrupt audiovec = { NULL, NULL, NT_INTERRUPT, 5, "audio_int", NULL, (void(*)(void))&AudioServer }; //* początek audiosig = AllocSignal( -1 ); if ( audiosig == -1 ) die("no free signals"); oldaudiovec = SetIntVector( INTB_AUD1, &audiovec ); ... // jeśli czekasz na koniec sampla, jeśli nie to ogarniasz inne funkcje obsługi sygnałów Wait( 1<<audiosig ); // koniec SetIntVector( INTB_AUD1, oldaudiovec ); if ( audiosig != -1 ) { FreeSignal( audiosig ); audiosig = -1; }
@asman, post #16
@asman, post #16
@Don_Adan, post #18
@Don_Adan, post #20
include hardware/custom.i ;----------------------------------------------------------------------------- XDEF _PlaySample ;a0 - address of sample (CHIP memory) ;d3 - length of sample ;a2 - address of empty sample _PlaySample: movem.l d0-a6,-(a7) lea $dff000,a5 lea $A0(a5),a1 ; channel 0 move.l a0,(a1) ;address of sample move.w d3,4(a1) ;size in words move.w #160,6(a1) ;period move.w #$40,8(a1) ;volume move.w #$8001,dmacon(a5) ;start move.b vhposr(A5),d1 .WaitLine3 cmp.b vhposr(A5),d1 ; sync routine to start at linestart beq.s .WaitLine3 .WaitDMA3 cmp.b #$16,vhposr+1(A5) ; wait til after Audio DMA slots bcs.s .WaitDMA3 ;set empty sfx move.l A2,(A1) move.w #1,4(A1) movem.l (A7)+,D0-A6 rts ;-----------------------------------------------------------------------------
@asman, post #21
@tukinem, post #24