Obligement - L'Amiga au maximum

Vendredi 06 juin 2025 - 12:29  

Translate

En De Nl Nl
Es Pt It Nl


Rubriques

Actualité (récente)
Actualité (archive)
Comparatifs
Dossiers
Entrevues
Matériel (tests)
Matériel (bidouilles)
Points de vue
En pratique
Programmation
Reportages
Quizz
Tests de jeux
Tests de logiciels
Tests de compilations
Trucs et astuces
Articles divers

Articles in English


Réseaux sociaux

Suivez-nous sur X




Liste des jeux Amiga

0, A, B, C, D, E, F,
G, H, I, J, K, L, M,
N, O, P, Q, R, S, T,
U, V, W, X, Y, Z,
ALL


Trucs et astuces

0, A, B, C, D, E, F,
G, H, I, J, K, L, M,
N, O, P, Q, R, S, T,
U, V, W, X, Y, Z


Glossaire

0, A, B, C, D, E, F,
G, H, I, J, K, L, M,
N, O, P, Q, R, S, T,
U, V, W, X, Y, Z


Galeries

Menu des galeries

BD d'Amiga Spécial
Caricatures Dudai
Caricatures Jet d'ail
Diagrammes de Jay Miner
Images insolites
Fin de jeux (de A à E)
Fin de Jeux (de F à O)
Fin de jeux (de P à Z)
Galerie de Mike Dafunk
Logos d'Obligement
Pubs pour matériels
Systèmes d'exploitation
Trombinoscope Alchimie 7
Vidéos


Téléchargement

Documents
Jeux
Logiciels
Magazines
Divers


Liens

Associations
Jeux
Logiciels
Matériel
Magazines et médias
Pages personnelles
Réparateurs
Revendeurs
Scène démo
Sites de téléchargement
Divers


Partenaires

Annuaire Amiga

Amedia Computer

Relec


A Propos

A propos d'Obligement

A Propos


Contact

David Brunet

Courriel

 


Programmation : Assembleur - Ensemble de Mandelbrot (deuxième partie)
(Article écrit par Emmanuel Hocdet et extrait d'Amiga News Tech - mai 1992)


Ce second volet vous fera découvrir dans toute sa splendeur le fameux ensemble de Mandelbrot. Alors plongez-vous vite dans le programme.

Pas de bla-bla... Les principales explications se trouvent dans l'article précédent. Juste quelques précisions :
  • La Mandelbrot est affichée en 32 couleurs (une couleur par itération). Après le calcul de chaque pixel, les bits du nombre d'itérations sont rangés dans les cinq plans de l'image, afin de lui faire correspondre une couleur précise.
  • Une option a été ajoutée, qui permet de remplir l'intérieur de la Mandelbrot de jolis dégradés. Avec le cycle de couleurs actif, c'est superbe...
  • Le zoom se manie à la souris : les boutons permettent d'agrandir ou de rétrécir le zoom. Le calcul est lancé par la touche F10. Bien sûr, il est assez rapidement limité puisqu'il ne s'effectue qu'en 16 bits. Pour la même raison, il n'est pas non plus nécessaire d'augmenter le nombre d'itérations.
  • Pour revenir à l'ensemble de départ, tapez F6. Les touches F1 à F5 servent au cycle de couleurs.
**** Traceur Manelbrot avec zoom par Emmanuel Hocdet
**** A assembler avec genim2

* F1  reset couleurs
* F2  cycle couleur vers l'exterieur
* F3  cycle couleur vers l'interieur
* F4	reduire la vitesse du cycle
* F5	accelerer la vitesse du cycle
* F6  Mandebrot d'origine
* F10 Calcul


	section	mandel,CODE_c

	bsr SaveAll
	bsr Main
	bsr RestoreAll
	rts
SaveAll:
	move.l	4,a6
	jsr	-132(a6)
	move.l	$6c,IrqVBL
	move.w	$dff01c,INTENA
	or.w	#$c000,INTENA
	move.w	$dff002,DMACON
	or.w	#$8100,DMACON
	rts
RestoreAll:
	move.w	#$7fff,$dff09a
	move.l	IrqVBL,$6c
	move.w	INTENA,$dff09a
	move.w	#$7fff,$dff096
	move.w	DMACON,$dff096
	move.l	4,a6
	lea	GFXlib(pc),a1
	moveq	#0,d0
	jsr	-552(a6)
	move.l	d0,a0
	move.l	38(a0),$dff080
	clr.w	$dff088
	move.l	d0,a1
	jsr	-414(a6)
	jsr	-138(a6)
	moveq	#0,d0
	rts
IrqVBL:	dc.l	0
INTENA:	dc.w	0
DMACON:	dc.w	0
GFXlib:	dc.b	"graphics.library",0
	even

**********************************************************************
*-----------interuptions--------------*
***************************************
ITclavier
	movem.l	d0-d7/a0-a6,-(sp)
	move	$dff01e,d0
	btst	#3,d0
	beq.s	FinIT
	move.b	$bfed01,d0
	btst	#3,d0
	beq.s	Pasclav
	moveq	#0,d0
	move.b	$bfec01,d0
	or.b	#$40,$bfee01
	not.b	d0
	ror.b	d0
TraiteClavier
	and	#$7f,d0		nega en posi
	sub	#$50,d0
	bmi.s	TooBig
	cmp	#$60-$50,d0
	bpl.s	TooBig
	add	d0,d0
	lea	TabTouche(pc),a0
	move	(a0,d0),d0
	lea	TT(pc),a0
	jsr	(a0,d0)	Sot a la touche appuyee

TooBig	and.b	#$bf,$bfee01
Pasclav	move	#$8,$dff09c
FinIT	movem.l	(sp)+,d0-d7/a0-a6
	rte
***************************************
ITcopper	* it sans cycle de couleurs
	movem.l d0-d7/a0-a6,-(sp)
	move	$dff01e,d0
	and	$dff01c,d0
	btst	#4,d0
	beq.s	F_Irq
	move	#$10,$dff09c
	bsr	Souris
F_Irq	movem.l (sp)+,d0-d7/a0-a6
	rte
ITcopper1	* it avec cycle de couleurs 1
	movem.l d0-d7/a0-a6,-(sp)
	move	$dff01e,d0
	and	$dff01c,d0
	btst	#4,d0
	beq.s	F_Irq1
	move	#$10,$dff09c
	bsr	Souris

	move	compt(pc),d0
	add	addition(pc),d0
	move	d0,compt
	cmp	#256,d0
	blt.s	F_Irq1
	clr.b	compt

	lea	Cycle_Colors(pc),a0
	lea	$dff180,a1
	move	Start(pc),d1
	addq.w	#2,Start
	moveq	#31,d0	
makcycl	subq	#2,d1
	and	#$3e,d1
	move	(a0,d1),(a1)+
	dbf	d0,makcycl

F_Irq1	movem.l (sp)+,d0-d7/a0-a6
	rte
ITcopper2	* it avec cycle de couleurs 2
	movem.l d0-d7/a0-a6,-(sp)
	move	$dff01e,d0
	and	$dff01c,d0
	btst	#4,d0
	beq.s	F_Irq2
	move	#$10,$dff09c
	bsr	Souris

	move	compt(pc),d0
	add	addition(pc),d0
	move	d0,compt
	cmp	#256,d0
	blt.s	F_Irq2
	clr.b	compt

	lea	Cycle_Colors(pc),a0
	lea	$dff180,a1
	move	Start(pc),d1
	subq.w	#2,Start
	moveq	#31,d0	
makcyc	subq	#2,d1
	and	#$3e,d1
	move	(a0,d1),(a1)+
	dbf	d0,makcyc

F_Irq2	movem.l (sp)+,d0-d7/a0-a6
	rte

Start		dc.w	0
addition	dc.w	128
compt		dc.w	0	
******************************************

TabTouche
	dc.w	F1-TT,F2-TT,F3-TT,F4-TT,F5-TT,F6-TT,Nil-TT,Nil-TT
	dc.w	Nil-TT,F10-TT,Nil-TT,Nil-TT,Nil-TT,Nil-TT,Nil-TT,Nil-TT
TT
F6
	move	#zoom*CLarg*8*2/4,x1
	move	#zoom*Haut/2,y1
	move	#zoom,zoomXY
F10	move	#1,NewCalc
	rts
Nil
	rts

F1	lea	Cycle_Colors+32*2,a0
	lea	$dff180,a1
	moveq	#31,d0
.loop	move	-(a0),(a1)+
	dbf	d0,.loop
	clr.w	Start
	move.l	#ITcopper,$6c.w
	rts
F2	move.l	#ITcopper1,$6c.w
	rts
F3	move.l	#ITcopper2,$6c.w
	rts

F4	lea	addition+1(pc),a0
	sub.b	#2,(a0)
	bne.s	pasmoin
	move.b	#2,(a0)
pasmoin	rts
F5	lea	addition+1(pc),a0
	add.b	#2,(a0)
	bne.s	pasplus
	move.b	#-2,(a0)
pasplus	rts
*********************************************
********* calcul du zoom maximum ************
Prep
	move	#Haut,LCoorsY
	move	#CLarg*8,d0
	move	d0,LCoorsX
	ext.l	d0
	divu	zoomXY(pc),d0
	bne.s	precis
	moveq	#1,d0
precis	move.l	d0,rest
	rts
rest	dc.w	0
quot	dc.w	0

Souris

***** gerer le zoom *****

	move.w	LCoorsX(pc),d2
	move.w	LpreciX(pc),d3
	move.w	quot(pc),d0
	move.w	rest(pc),d1

	btst 	#6,$bfe001	Left botton
	bne.s	grand
	add.w	d1,d3
	addx.w	d0,d2
	cmp.w	#CLarg*8,d2
	bgt.s	petit
	move	d2,LCoorsX
	move	d3,LpreciX
	mulu	#minY,d2
	divu	#minX,d2
	move	d2,LCoorsY
	bra.s	petit
grand	btst	#10,$dff016	Right botton
	bne.s	petit
	sub.w	d1,d3
	subx.w	d0,d2
	cmp	#minX,d2
	blt.s	petit
	move	d2,LCoorsX
	move	d3,LpreciX
	mulu	#minY,d2
	divu	#minX,d2
	move	d2,LCoorsY
petit

******** gerer le mouvement de la souris ********
	lea	Smem(pc),a0
	move.b	(a0),d2
	move.b	1(a0),d3
	move	$dff00a,(a0)
	move.b	(a0),d0
	move.b	1(a0),d1
	ext	d0
	ext	d1
	ext	d2
	ext	d3
	sub	d0,d2
	sub	d1,d3
	move.b	d2,d0
	move.b	d3,d1
	neg.b	d0
	neg.b	d1
	ext	d0
	ext	d1
	sub	d1,d3
	beq.s	nox
	lea	posiX(pc),a0
	add	(a0),d1
****traiter X
	bpl.s	Xposi
	moveq	#0,d1
Xposi	move	d1,(a0)
nox	sub	d0,d2
	beq.s	noy
	lea	posiY(pc),a0
	add	(a0),d0
****traiter Y
	bpl.s	Yposi
	moveq	#0,d0
Yposi	move	d0,(a0)
noy

	move	#CLarg*8,d0
	sub	LCoorsX(pc),d0
	lea	posiX(pc),a0
	cmp	(a0),d0
	bge.s	catienX
	move	d0,(a0)
catienX
	move	#Haut,d0
	sub	LCoorsY(pc),d0
	lea	posiY(pc),a0
	cmp	(a0),d0
	bge.s	catienY
	move	d0,(a0)
catienY

********* les sprites ********

	lea	posiX(pc),a0
	lea	posiY(pc),a1
	move	(a1),d0
	move	(a0),d2
	add.w	#fymin,d0
	add.w	#fxmin,d2
	bsr	Sptmot
	move.l	d0,hg

	move	(a1),d0
	move	(a0),d2
	add.w	#fymin,d0
	add.w	#fxmin-16-1,d2
	add.w	LCoorsX(pc),d2
	bsr	Sptmot
	move.l	d0,hd

	move	(a1),d0
	move	(a0),d2
	add.w	#fymin-16,d0
	add.w	LCoorsY(pc),d0
	add.w	#fxmin-16-1,d2
	add.w	LCoorsX(pc),d2
	bsr	Sptmot
	move.l	d0,bd

	move	(a1),d0
	move	(a0),d2
	add.w	#fymin-16,d0
	add.w	LCoorsY(pc),d0
	add.w	#fxmin,d2
	bsr	Sptmot
	move.l	d0,bg

	bsr	Sprits
	rts

Sptmot
	move	d0,d1
	add	#16,d1
	moveq	#0,d3
	lsl.w	#8,d0
	addx	d3,d3
	lsl.w	#8,d1
	addx	d3,d3
	lsr.w	#1,d2
	addx	d3,d3
	or.w	d2,d0
	or.w	d3,d1
	swap	d0
	move	d1,d0
	rts

Sprits	lea	$dff120,a6
	move.l	#hg,(a6)+
	move.l	#bd,(a6)+
	move.l	#bg,(a6)+
	move.l	#hd,(a6)+
	moveq	#3,d7
loop	move.l	#Nil,(a6)+
	dbf	d7,loop
	rts


Smem	dc.w	0
posiX	dc.w	0
posiY	dc.w	0

LCoorsX	dc.w	0
LCoorsY	dc.w	0
LpreciX	dc.w	0

minX=20
minY=17

zoom=$80
x1	dc.w	zoom*CLarg*8*2/4
y1	dc.w	zoom*Haut/2
zoomXY	dc.w	zoom
YY	dc.w	0
XX	dc.w	0
incx	dc.w	0
incy	dc.w	0
*********************************************
**************  Initialisation **************

Main
	lea	$dff000,a6
	move	#$7fff,$96(a6)
	move	#$7fff,$9a(a6)
	bsr	F1
	move	$dff00a,Smem

	lea	BITPLAN,a0
	move.l	a0,d1
	lea	plans,a1
	moveq	#4,d0
cree	lea	2(a1),a1
	swap	d1
	move	d1,(a1)+
	lea	2(a1),a1
	swap	d1
	move	d1,(a1)+
	add.l	#taille,d1
	dbf	d0,cree

	move.l	#ITcopper,$6c.w
	move	#$c010,$9a(a6)
	move.l	#ITclavier,$68.w
	move	#$8008,$9a(a6)
	move.l	#copper_list,$80(a6)
	clr.w	$88(a6)
	move.w	#$64,$104(a6)
	move.w	#$11,$102(a6)
	move	#$83a0,$96(a6)


Haut=34*8
Larg=40
CLarg=40

fymin=$20
fymax=$30
fxmin=$81
fxmax=$c1
bxmin=$38
bxmax=$d0

Mandel
	bsr	Prep

	clr.w	YY
	move	y1(pc),d0
	neg	d0
	move	d0,incy

LOOP1	
	clr.w	XX
	move	x1(pc),d0
	neg	d0
	move	d0,incx
	move	incy(pc),a6		=Im
	move	zoomXY(pc),d0
	add	d0,incy

LOOP2

	moveq	#15,d4
Le_mot

	move.w	incx(pc),a5		=Re
	move	zoomXY(pc),d0
	add	d0,incx
	
	moveq	#0,d0
	moveq	#0,d1
	moveq	#0,d2
	moveq	#0,d3

	moveq	#30,d7	*nbs d'iterations
LOOP3
	sub.l	d3,d2		*******************
	lsl.l	#3,d2		* x=x-y+p0 	  	*
	swap	d2		*			*
	add.w	a5,d2		*******************
				
	move.w	d1,d3		*******************
	muls	d0,d3		*		  	*
	lsl.l	#4,d3		* y=2*x*y+q0   	*	
	swap	d3		*			*
	add.w	a6,d3		*******************

	move.w	d2,d0		*******************
	move.w	d3,d1		*			*
	muls	d2,d2		* module=x^2+y^2	*	
	muls	d3,d3		*		  	*
	move.l	d2,d6		*		  	*
	add.l	d3,d6		*******************

	cmp.l	#$10000000,d6	test (4<<13)*2
* essayer   $20000000 et  $40000000
	dbhi	d7,LOOP3


********* **********
	bpl.s	OUT
	swap	d6
;	lsr	#3,d6
	and	#31<<3,d6
	move	d6,d7
	bra.s	IN
***************************

OUT
	addq.w	#2,d7
	lsl	#3,d7
IN
******* repartition de la couleur de chaque
******* pixel dans les 5 plans

	add.b	d7,d7	btpl5
	addx	d5,d5
	move	a4,d2	btpl4
	add.b	d7,d7
	addx	d2,d2
	move	d2,a4
	move	a3,d2	btpl3
	add.b	d7,d7
	addx	d2,d2
	move	d2,a3
	move	a2,d2	btpl2
	add.b	d7,d7
	addx	d2,d2
	move	d2,a2
	move	a1,d2	btpl1
	add.b	d7,d7
	addx	d2,d2
	move	d2,a1

	dbf	d4,Le_mot

******* Affichage dans les 5 plans

	move.w	YY(pc),d1
	add.w	XX(pc),d1

	lea	BITPLAN,a0
	move.w	a1,(a0,d1)
	lea	taille(a0),a0
	move.w	a2,(a0,d1)
	lea	taille(a0),a0
	move.w	a3,(a0,d1)
	lea	taille(a0),a0
	move.w	a4,(a0,d1)
	lea	taille(a0),a0
	move.w	d5,(a0,d1)

	add.w	#2,XX

C0	btst	#10,$dff016
	bne.s	noEXIT
	btst	#6,$bfe001
	beq.s	EXIT
noEXIT
	cmp.w	#CLarg,XX
	bmi	LOOP2

	tst	NewCalc
	bne.s	NewPosi

	add.w	#Larg,YY
	cmp.w	#Larg*Haut,YY
	bmi	LOOP1

recom
	tst	NewCalc
	bne.s	NewPosi

	btst	#10,$dff016
	bne.s	recom
	btst	#6,$bfe001
	bne.s	recom
EXIT	rts

********** Calcul du pas (zoom)

NewCalc	dc.w	0
NewPosi
	clr	NewCalc
	lea	zoomXY(pc),a0
	move	(a0),d0
	move	posiX(pc),d1
	mulu	d0,d1
	sub	d1,x1
	move	posiY(pc),d1
	mulu	d0,d1
	sub	d1,y1
	move	LCoorsX(pc),d1
	subq	#1,d1
	mulu	d1,d0
	divu	#CLarg*8,d0
	addq	#1,d0
	move	d0,(a0)

	bra	Mandel

Cycle_Colors
	dc.w	$bbf,$99f,$78f,$57f,$36f,$25e,$35d,$45c,$55b,$64a
	dc.w	$749,$848,$947,$a36,$b35,$c34,$d43,$e42
	dc.w	$f41,$f51,$f61,$f71,$f81,$f91,$fa1,$fb1
	dc.w	$fc1,$fc3,$fd5,$fd7,$fe9,$eec

*****************
copper_list
	dc.l	$009c8010
plans	dc.w	$e0,0,$e2,0
	dc.w	$e4,0,$e6,0
	dc.w	$e8,0,$ea,0
	dc.w	$ec,0,$ee,0
	dc.w	$f0,0,$f2,0

	dc.l	$01005200
	dc.b	$00,$8e,fymin,fxmin
	dc.b	$00,$90,fymax,fxmax
	dc.w	$0092,bxmin
	dc.w	$0094,bxmax

	dc.l	$01080000
	dc.l	$010a0000

	dc.l	$aae1fffe
	dc.l	$fffffffe

************* Sprites **********

hg	
	dc.w $2940,$3901
	dc.l $FFFF
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l $8000
	dc.l 0
bd	
	dc.w $2940,$3901
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $0001
	dc.l $FFFF
	dc.l 0

hd
	dc.w $2940,$3901
	dc.w $FFFF,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.w $0001,0
	dc.l 0

bg
	dc.w $2940,$3901
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $8000,0
	dc.w $FFFF,0
	dc.l 0

taille=Larg*Haut

BITPLAN ds.b  taille*5


[Retour en haut] / [Retour aux articles] [Article précédent]