Voici le source d'une lib que j'avais commencé .. Attention, le gray7 ne marche pas !!!
Le gray4 est oki !
J'utilise l'auto int 5 pour faire du gris "reglable" (etre synchro avec l'ecran!)
Alors voilà lorsque l'interruption arrive, le micro arrete ce qu'il fait pour executer une certaine sequence de code et puis, une fois terminé (RTE) il reprend là ou il est etait !
---------------------------------------------------
include "doorsos.h"
xdef _ti89
xdef _ti92plus
xdef _exit
xdef _library
xdef graylib@0000 ;func grayoff
xdef graylib@0001 ;func gray4
xdef graylib@0002 ;func gray7
xdef graylib@0003 ;func inc rate
xdef graylib@0004 ;func dec rate
xdef graylib@0005 ;var plane0
xdef graylib@0006 ;var plane1
xdef graylib@0007 ;var plane2
xdef graylib@0008 ;var rat
;*******************************************************************************
;**** Gray OFF
;**** Detruit la mémoire et restore l'auto int 5
;**** Ne détruit rien
;*******************************************************************************
_exit:
graylib@0000:
Gray_Off:
movem.l d0-d7/a0-a6,-(a7)
tst.l old_int5
beq Gray_off_Failed
move.w #$0700,d0 ;
trap #1 ; ints off
bclr.b #2,($600001) ; mem protection off
move.l old_int5,($74) ; installes the old int 5
bset.b #2,($600001) ; mem prot on
clr.w d0
trap #1 ; ints on
clr.l old_int5
move.b #$B2,($600017) ; set l'auto int5 a 18Hz
move.w Handle_Plan,-(sp)
jsr doorsos::HeapFree
add.l #2,sp
clr.w Handle_Plan
Gray_off_Failed:
movem.l (a7)+,d0-d7/a0-a6
clr.l d0
rts
;*******************************************************************************
;*******************************************************************************
;**** Gray 4
;**** Réserve la mémoire et détourne l'auto int 5
;**** Ne détruit rien
;*******************************************************************************
graylib@0001:
Gray_4:
movem.l d0-d7/a0-a6,-(a7)
move.l #(2*3840)+1,-(sp) ; reserve 2 ecran : 3840*2=7680
bsr Reserve_Memory
move.l d0,plan0 ; on sauvegarde adresse ecran 0
add.l #3840,d0
move.l d0,plan1 ; on sauvegarde adresse ecran 1
;******* Memoire Reservée et handle saved *******
move.b #$eb,rate ; $eb pour HW1 et $f6 pour HW2
clr.b HBL_Phase
move.w #$2700,d0
trap #1 ; ints off
move.l $74,old_int5 ; saves the old int 1 handler
bclr.b #2,($600001) ; mem protection off
move.l #Gray4_Manager,($74) ; installe notre int
bset.b #2,($600001) ; mem prot on
clr.w d0
trap #1 ; ints on
bsr Sync_Now ; force le balayage
; + reinit compteur int5
movem.l (a7)+,d0-d7/a0-a6
move.l #1,d0 ; succes !!!
rts
;*******************************************************************************
;**** Gray 7
;**** Réserve la mémoire et détourne l'auto int 5
;**** Ne détruit rien
;*******************************************************************************
graylib@0002:
Gray_7:
movem.l d0-d7/a0-a6,-(a7)
move.l #(3*3840)+1,-(sp) ; reserve 2 ecran : 3840*2=7680
bsr Reserve_Memory
move.l d0,plan0 ; on sauvegarde adresse ecran 0
add.l #3840,d0
move.l d0,plan1 ; on sauvegarde adresse ecran 1
add.l #3840,d0
move.l d0,plan2 ; on sauvegarde adresse ecran 1
;******* Memoire Reservée et handle saved *******
move.b #$eb,rate ; $eb pour HW1 et $f6 pour HW2
clr.b HBL_Phase
move.w #$2700,d0
trap #1 ; ints off
move.l $74,old_int5 ; saves the old int 1 handler
bclr.b #2,($600001) ; mem protection off
move.l #Gray7_Manager,($74) ; installe notre int
bset.b #2,($600001) ; mem prot on
clr.w d0
trap #1 ; ints on
bsr Sync_Now ; force le balayage
; + reinit compteur int5
movem.l (a7)+,d0-d7/a0-a6
move.l #1,d0 ; succes !!!
rts
;*******************************************************************************
; Reserve_Memory
; Reserve le nb d'octet deposé sur la pile + stock le handle ds Handl_Plan
;
; Detruit d1,a0,a1,a6
; d0 = adresse paire de la memoire !
;*******************************************************************************
Reserve_Memory:
move.l (sp)+,a6
jsr doorsos::HeapAllocHigh
add.l #4,sp
tst.w d0
beq Reserve_Failed
move.l a6,-(sp)
move.w d0,Handle_Plan
doorsos:

EREF d0,a0
move.l a0,d0
btst.b #0,d0
beq adresse_plan_paire
add.l #1,d0
adresse_plan_paire:
rts
;*******************************************************************************
Reserve_Failed:
movem.l (a7)+,d0-d7/a0-a6
move.l #0,d0 ; erreur !!!
rts
;*******************************************************************************
;*******************************************************************************
;* Icremente la frequence de rafraichissement
;*******************************************************************************
graylib@0003:
add.b #1,rate
bsr Sync_Now
rts
;*******************************************************************************
;* Icremente la frequence de rafraichissement
;*******************************************************************************
graylib@0004:
sub.b #1,rate
bsr Sync_Now
rts
;*******************************************************************************
;***************************** LES INTERRUPTIONS ******************************
;*******************************************************************************
Gray4_Manager:
movem.l d0-d7/a0-a6,-(a7)
move.w #$2700,sr ; on interdit les autre
; auto-ints
add.b #1,HBL_Phase
and.b #3,HBL_Phase
cmp.b #1,HBL_Phase
blt Load_Screen0 ; on afiche l'image0 1 * sur 3
move.l plan1,a1
bra Display_Plane
Load_Screen0:
move.l plan0,a1
bra Display_Plane
Gray7_Manager:
movem.l d0-d7/a0-a6,-(a7)
move.w #$2700,sr ; on interdit les autre
; auto-ints
add.b #1,HBL_Phase
and.b #7,HBL_Phase
cmp.b #1,HBL_Phase
blt Load_Screen0 ; on afiche l'image0 1 * sur 6
cmp.b #3,HBL_Phase
blt Load_Screen1 ; on afiche l'image1 2 * sur 6
move.l plan2,a1 ; 4 * / 6
bra Display_Plane
Load_Screen1:
move.l plan1,a1
bra Display_Plane
Display_Plane:
lea $4c00,a0
move.l #959,d0
Update_Screen:
move.l (a1)+,(a0)+ ; on copie aa l'ecran
dbra d0,Update_Screen
movem.l (a7)+,d0-d7/a0-a6
move.l old_int5,-(sp)
rts ; on execute la old int 5
;*******************************************************************************
;**** Synchronize NOW !
;**** Synchronisation avec l'ecran, +1 cmpteur
;**** Ne détruit rien
;*******************************************************************************
Sync_Now:
move.b rate,($600017) ; set l'auto int5
move.b #80,($600013) ; force le pic a recommencer le
; balayage
rts
;******************************************************************************
;*************************** LES VARIABLES ************************************
;******************************************************************************
EVEN
graylib@0005
plan0: dc.l 0
graylib@0006
plan1: dc.l 0
graylib@0007
plan2: dc.l 0
old_int5: dc.l 0
Handle_Plan: dc.w 0
HBL_Phase: dc.b 0
graylib@0008
rate: dc.b 0
END