Je vais diffuser tout le code.
Ca c'est la librairie:
; Assembly Source File
; Created 07/04/03, 11:37:55
include "doorsos.h"
include "hexlib.h"
xdef _library
xdef _ti89
xdef _ti92plus
;Fonctions sonore destiné surtout aux jeux
xdef polysnd2@0000
xdef polysnd2@0001
xdef polysnd2@0002
xdef polysnd2@0003
xdef polysnd2@0004
xdef polysnd2@0005
xdef polysnd2@0006
xdef polysnd2@0007
xdef polysnd2@0008
xdef polysnd2@0009
xdef polysnd2@000A
xdef polysnd2@000B
xdef polysnd2@000C
xdef polysnd2@000D
xdef polysnd2@000E
xdef polysnd2@000F
xdef polysnd2@0010
_BEEP EQU 1
_DATA EQU 2
_STOP EQU 0
_START EQU 1
_NOLOOP EQU 0
_LOOP EQU 1
_NOVOICE EQU 0
_VOICE1 EQU 1
_VOICE2 EQU 2
_ALLVOICE EQU 3
;**************************************************
;Active l'utilisation du port I/O pour faire du son
;**************************************************
polysnd2@0000:
EnabledSound:
bset #6,($60000C) ;Initialise le port IO soit le byte 6 mie à 1
move.w #%00101000,($60000C) ;Accès au port I/O
bclr #0,($60000E) ;Initialise l'écouteur gauche
bclr #1,($60000E) ;Initialise l'écouteur droit
rts
;**********************************************
;Remet à la normal l'utilisation du port I/O
;**********************************************
polysnd2@0001:
DisabledSound:
bclr #0,($60000E) ;Etat d'origine du port I/O (+5 V)
bclr #1,($60000E) ;Etat d'origine du port I/O (+5 V)
move.b #$8D,($60000C) ;Accès normal au port I/O
rts
;************************************
;Installation de l'interruption audio
;************************************
polysnd2@0002:
InstallSound:
bsr __Initialize
move.l #empty_handler,interrupt_handler
;Active l'interruption n°5
movem.l d0,-(a7) ;Sauvegarde de d0
move.b ($600015),backup_600015 ;Sauvegarde du port 600015
move.w #$0700,d0 ;Désactive toutes les interruptions
trap #1 ;Effectué par trap #1
move.b #40,$60000C ;Init Full I/O Access
move.b #$FF,$600017 ;Reprogram timer to max
move.b #$0B,$600015 ;Init 22kHz Timer (HW1=22 Khz, HW2=8Khz)
move.l $74,old_int5 ;Sauvegarde de l'ancien adresse de int5
bclr.b #2,($600001) ;Désactive la protection d'écriture dans la table vectorielle
move.l #int5_handler,$74 ;Met l'adresse dans la table vectorielle
bset.b #2,($600001) ;Active la protection en écriture de la table vectorielle
move.w #0,d0 ;Met 0 dans d0
trap #1 ;Exécute interruptions (rétablit interruptions)
movem.l (a7)+,d0 ;Charge de d0
rts
;***************************************
;Desinstallation de l'interruption audio
;***************************************
polysnd2@0003:
DesinstallSound:
;Désactive l'interruption n°5
movem.l d0,-(a7) ;Sauvegarde d0
move.w #$0700,d0 ;Désactive toutes les interuptions
trap #1 ;Effectué par trap #1
move.b backup_600015,($600015) ;Restaure le port 600015
move.b #$B2,($600017) ;Remet à l'origine le port 600017
bclr.b #2,($600001) ;Désactive la protection en écriture dans la table vectorielle
move.l old_int5(PC),$74 ;Remet l'ancienne interruption
bset.b #2,$600001 ;Active la protection en écriture de la table vectorielle
move.w #0,d0 ;Réactive toutes les interuptions
trap #1 ;Effectué par trap #1
movem.l (a7)+,d0 ;Restaure d0
rts
;*************************************
;Initialise variables audio
;*************************************
polysnd2@0004:
__Initialize:
;Remet à zéro toutes les variables
clr.w _fcounter1
clr.w _fcounter2
clr.w frequency_voice1
clr.w frequency_voice2
clr.w _ucounter1
clr.w _ucounter2
clr.b lenght_voice1
clr.b lenght_voice2
clr.b _lcounter1
clr.b _lcounter2
clr.l time_counter_voice1
clr.l time_counter_voice2
clr.b mode
clr.b state
clr.b loop
rts
;**************************************
;Réglage des tempo (unittps) //Voice1\
;**************************************
polysnd2@0005:
SetTempo_voice1:
clr.w _ucounter1
clr.w _fcounter1
movem.l d0-d1,-(a7)
move.w 12(a7),d0
move.w #15960,d1
divu.w d0,d1
move.w d1,unittps_voice1
movem.l (a7)+,d0-d1
rts
;**************************************
;Réglage des tempo (unittps) //Voice2\
;**************************************
polysnd2@0006:
SetTempo_voice2:
clr.w _ucounter2
clr.w _fcounter2
movem.l d0-d1,-(a7)
move.w 12(a7),d0
move.w #15960,d1
divu.w d0,d1
move.w d1,unittps_voice2
movem.l (a7)+,d0-d1
rts
;*************************************
;Renvoie le tempo (unittps) //Voice1\
;*************************************
polysnd2@0007:
GetTempo_voice1:
move.l d1,-(a7)
move.w unittps_voice1,d0
move.w #15960,d1
divu.w d0,d1
move.w d1,d0
move.l (a7)+,d1
rts
;*************************************
;Renvoie le tempo (unittps) //Voice2\
;*************************************
polysnd2@0008:
GetTempo_voice2:
move.l d1,-(a7)
move.w unittps_voice2,d0
move.w #15960,d1
divu.w d0,d1
move.w d1,d0
move.l (a7)+,d1
rts
;**********************************************
;SetState (Régle start ou stop sur chaque voix
;**********************************************
polysnd2@0009:
SetState:
move.b 4(a7),state
rts
;**********************************************
;SetLoop (Régle loop sur chaque voix
;**********************************************
polysnd2@000A:
SetLoop:
move.b 4(a7),loop
rts
;*************************************
;BEEP réglage sur voix1
;*************************************
polysnd2@000B:
SetBeep_voice1:
clr.w _ucounter1
clr.w _fcounter1
clr.w frequency_voice1
clr.l time_counter_voice1
move.b 4(a7),lenght_voice1
move.w 6(a7),frequency_voice1
move.w unittps_voice1,_ucounter1
move.w frequency_voice1,_fcounter1
move.b lenght_voice1,_lcounter1
bset.b #0,state
bclr.b #0,mode
rts
;*************************************
;BEEP réglage sur voix2
;*************************************
polysnd2@000C:
SetBeep_voice2:
clr.w _ucounter2
clr.w _fcounter2
clr.w frequency_voice2
clr.l time_counter_voice2
move.b 4(a7),lenght_voice2
move.w 6(a7),frequency_voice2
move.w unittps_voice2,_ucounter2
move.w frequency_voice2,_fcounter2
move.b lenght_voice2,_lcounter2
bset.b #1,state
bclr.b #1,mode
rts
;*************************************
;BEEP réglages sur 2 voix
;*************************************
polysnd2@000D:
beep:
clr.w _ucounter1
clr.w _ucounter2
clr.w _fcounter1
clr.w _fcounter2
clr.w frequency_voice1
clr.w frequency_voice2
clr.l time_counter_voice1
clr.l time_counter_voice2
move.b 4(a7),lenght_voice2
move.b 6(a7),lenght_voice1
move.w 8(a7),frequency_voice2
move.w 10(a7),frequency_voice1
move.w unittps_voice1,_ucounter1
move.w unittps_voice2,_ucounter2
move.w frequency_voice1,_fcounter1
move.w frequency_voice2,_fcounter2
move.b lenght_voice1,_lcounter1
move.b lenght_voice2,_lcounter2
move.b #3,state
clr.b mode
rts
;*************************************
;PLAYFX réglages sur voix 1
;*************************************
polysnd2@000E:
PlayFX_voice1:
clr.w _ucounter1
clr.w _fcounter1
clr.w frequency_voice1
clr.b _lcounter1
clr.b lenght_voice1
clr.l time_counter_voice1
move.l 4(a7),ptrstart_voice1
move.l ptrstart_voice1,ptridle_voice1
bset.b #0,state
bset.b #0,mode
rts
;*************************************
;PLAYFX réglages sur voix 2
;*************************************
polysnd2@000F:
PlayFX_voice2:
clr.w _ucounter2
clr.w _fcounter2
clr.w frequency_voice2
clr.b _lcounter2
clr.b lenght_voice2
clr.l time_counter_voice2
move.l 4(a7),ptrstart_voice2
move.l ptrstart_voice1,ptridle_voice2
bset.b #1,state
bset.b #1,mode
rts
;*************************************
;PLAYFX réglages sur 2 voix
;*************************************
polysnd2@0010:
PlayFX:
clr.w _ucounter1
clr.w _ucounter2
clr.w _fcounter1
clr.w _fcounter2
clr.w frequency_voice1
clr.w frequency_voice2
clr.b _lcounter1
clr.b _lcounter2
clr.b lenght_voice1
clr.b lenght_voice2
clr.l time_counter_voice1
clr.l time_counter_voice2
move.l 4(a7),ptrstart_voice2
move.l 6(a7),ptrstart_voice1
move.l ptrstart_voice1,ptridle_voice1
move.l ptrstart_voice2,ptridle_voice2
move.b #3,state
move.b #3,mode
rts
;/////////////////////////////////////////////////////////
;Méthode pour jouer des fréquences sur 2 voix avec unittps
;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
;------
;Voice1
play_voice1:
move.l d0,-(a7)
move.w frequency_voice1,d0
add.w d0,_fcounter1
cmp.w #65000,_fcounter1
bge son_1
tst.w frequency_voice1
beq son_1
clr.w _fcounter1
bchg #0,($60000E)
;subq.w #1,_ucounter1
son_1:
subq.w #1,_ucounter1
move.l (a7)+,d0
rts
;------
;Voice2
play_voice2:
move.l d0,-(a7)
move.w frequency_voice2,d0
add.w d0,_fcounter2
cmp.w #65000,_fcounter2
bge son_2
tst.w frequency_voice2
beq son_2
clr.w _fcounter2
bchg #1,($60000E)
;subq.w #1,_ucounter2
son_2:
subq.w #1,_ucounter2
move.l (a7)+,d0
rts
;-------------------------------------------------
;INTERRUPTION AUDIO
;-------------------------------------------------
;*************************************************
;int_5: Interruption de gestion audio ~8192 hz
;*************************************************
int5_handler:
move.w #$2700,sr
btst.b #0,state
beq done_voice1
addq.l #1,time_counter_voice1
btst.b #0,mode
beq beep_voice1
bra data_voice1
done_voice1:
btst.b #1,state
beq done_voice2
addq.l #1,time_counter_voice2
btst.b #1,mode
beq beep_voice2
bra data_voice2
done_voice2:
done:
move.l interrupt_handler,-(a7)
rts
;-*-*-*-*-*-*-*-*-*-*
;Fonction BEEP voix 1
;*-*-*-*-*-*-*-*-*-*-
beep_voice1:
tst.w _ucounter1
beq done_unittps_beep_voice1
bsr play_voice1
bra done_voice1
done_unittps_beep_voice1:
subq.b #1,_lcounter1
tst.b _lcounter1
beq done_lenght_beep_voice1
move.w unittps_voice1,_ucounter1
bra done_voice1
done_lenght_beep_voice1:
clr.l time_counter_voice1
btst.b #0,loop
bne init_unittps_voice1
bclr.b #0,state
bra done_voice1
init_unittps_voice1:
move.w unittps_voice1,_ucounter1
move.b lenght_voice1,_lcounter1
bra done_voice1
;-*-*-*-*-*-*-*-*-*-*
;Fonction BEEP voix 2
;*-*-*-*-*-*-*-*-*-*-
beep_voice2:
tst.w _ucounter2
beq done_unittps_beep_voice2
bsr play_voice2
bra done_voice2
done_unittps_beep_voice2:
subq.b #1,_lcounter2
tst.b _lcounter2
beq done_lenght_beep_voice2
move.w unittps_voice1,_ucounter2
bra done_voice2
done_lenght_beep_voice2:
clr.l time_counter_voice2
btst.b #1,loop
bne init_unittps_voice2
bclr.b #1,state
bra done_voice2
init_unittps_voice2:
move.w unittps_voice2,_ucounter2
move.b lenght_voice2,_lcounter2
bra done_voice2
;-*-*-*-*-*-*-*-*-*-*-*-*
;Extraction PLAYFX voix 1
;*-*-*-*-*-*-*-*-*-*-*-*-
data_voice1:
tst.w _ucounter1
beq done_unittps_playfx_voice1
bsr play_voice1
bra done_voice1
done_unittps_playfx_voice1:
tst.b _lcounter1
beq done_lenght_playfx_voice1
subq.b #1,_lcounter1
move.w unittps_voice1,_ucounter1
bra done_voice1
done_lenght_playfx_voice1:
move.w unittps_voice1,_ucounter1
bsr extract_voice1
bra done_voice1
extract_voice1:
move.l a0,-(a7)
move.l ptridle_voice1,a0
move.w (a0)+,frequency_voice1
;move.b (a0)+,_lcounter1
move.l (a7)+,a0
addq.l #2,ptridle_voice1
move.b _lcounter1,lenght_voice1
cmp.w #$FFFF,frequency_voice1
beq end_playfx_voice1
rts
end_playfx_voice1:
clr.l time_counter_voice1
btst.b #0,loop
bne init_playfx_voice1
bclr.b #0,state
bra done_voice1
init_playfx_voice1:
move.l ptrstart_voice1,ptridle_voice1
bra done_voice1
;-*-*-*-*-*-*-*-*-*-*-*-*
;Extraction PLAYFX voix 2
;*-*-*-*-*-*-*-*-*-*-*-*-
data_voice2:
tst.w _ucounter2
beq done_unittps_playfx_voice2
bsr play_voice2
bra done_voice2
done_unittps_playfx_voice2:
tst.b _lcounter2
beq done_lenght_playfx_voice2
subq.b #1,_lcounter2
move.w unittps_voice2,_ucounter2
bra done_voice2
done_lenght_playfx_voice2:
move.w unittps_voice2,_ucounter2
bsr extract_voice2
bra done_voice2
extract_voice2:
move.l a0,-(a7)
move.l ptridle_voice2,a0
move.w (a0)+,frequency_voice2
;move.b (a0)+,_lcounter2
move.l (a7)+,a0
addq.l #2,ptridle_voice2
move.b _lcounter2,lenght_voice2
cmp.w #$FFFF,frequency_voice2
beq end_playfx_voice2
rts
end_playfx_voice2:
clr.l time_counter_voice2
btst.b #1,loop
bne init_playfx_voice2
bclr.b #1,state
bra done_voice2
init_playfx_voice2:
move.l ptrstart_voice2,ptridle_voice2
bra done_voice2
;--------------------------------------------------------------------------------------------
empty_handler:
rte
even
backup_600015 dc.l 0
old_int5 dc.l 0
interrupt_handler dc.l 0
unittps_voice1 dc.w 0
unittps_voice2 dc.w 0
_ucounter1 dc.w 0
_ucounter2 dc.w 0
frequency_voice1 dc.w 0
frequency_voice2 dc.w 0
_fcounter1 dc.w 0
_fcounter2 dc.w 0
lenght_voice1 dc.b 0
lenght_voice2 dc.b 0
_lcounter1 dc.b 0
_lcounter2 dc.b 0
time_counter_voice1 dc.l 0
time_counter_voice2 dc.l 0
mode dc.b 0
state dc.b 0
loop dc.b 0
ptrstart_voice1 dc.l 0
ptrstart_voice2 dc.l 0
ptridle_voice1 dc.l 0
ptridle_voice2 dc.l 0
end
; move.w unittps,d0
; move.l #0,d1
; move.l #0,d2
; move.l #7,d4
; jsr hexlib::put_hex
Le programme:
; Assembly Source File
; Created 10/05/2003, 21:24:35
include "doorsos.h"
include "polysnd2.h"
include "hexlib.h"
xdef _ti89
xdef _ti92plus
xdef _main
_main
move.w #120,-(a7)
jsr polysnd2:

etTempo_voice1
lea 2(a7),a7
move.w #120,-(a7)
jsr polysnd2:

etTempo_voice2
lea 2(a7),a7
jsr polysnd2::EnabledSound
jsr polysnd2::InstallSound
jsr polysnd2::GetTempo_voice1
move.l #0,d1
move.l #0,d2
move.l #3,d4
jsr hexlib:

ut_hex
jsr polysnd2::GetTempo_voice2
move.l #1,d1
move.l #0,d2
move.l #3,d4
jsr hexlib:

ut_hex
move.b #_ALLVOICE,-(a7)
jsr polysnd2:

etLoop
lea 2(a7),a7
pea channel2
pea channel2
jsr polysnd2::PlayFX
lea 8(a7),a7
suite:
;Test [ESC]
move.w #8,d0
bsr masque
btst.b #6,d0
bne suite
jsr polysnd2:

esinstallSound
jsr polysnd2:

isabledSound
rts
;--------------------------------------------
;Masque pour la lecture du clavier
;********************************************
;********************************************
;masque une ligne du clavier
;--------------------------------------------
;d0=ligne -> d0=réponse
;********************************************
masque:
movem.l d1,-(a7)
move.w #$FFFE,d1
rol.w d0,d1
clr.w d0
move.w d1,($600018)
nop
nop
nop
nop
nop
nop
move.b ($60001B),d0
movem.l (a7)+,d1
RTS
even
channel2:
dc.w 3000,1100,0,65535
end
Problème dans la librairie ligne 537 et 586.