Update.
[turmites.git] / Turmites.s
1
2 ;       TURMITES  (c) F.Fleuret 28/11/89
3 ;               version assembleur AMIGA
4
5 ; opt d+                        ; option d'assemblage (sauve les labels)
6
7 ExecBase=4
8
9 OldOpenLibrary=-408
10 CloseLibrary=-414
11 Forbid=-132
12 AllocMem=-198
13 FreeMem=-210
14 FindTask=-294
15 WaitPort=-384
16 GetMsg=-372
17 ReplyMsg=-378
18
19 DisplayAlert    equ     -90
20
21 pr_CLI=$AC
22 pr_MsgPort=$5C
23
24 Frequence       =       500
25
26 ntur    equ     1024    ; nombre maximum de turmites
27
28 X       equ     0       ; abscisse
29 Y       equ     2       ; ordonnée
30 E       equ     4       ; état
31 O       equ     6       ; orientation
32 V       equ     8       ; niveau d'énergie
33 Table   equ     10      ; table de comportement
34
35 ndatas  equ     58
36
37 Startup:
38         sub.l   a1,a1
39         move.l  ExecBase,a6
40         jsr     FindTask(a6)
41         move.l  d0,a2
42         tst.l   pr_CLI(a2)
43         bne.s   FromCLI
44
45         lea     pr_MsgPort(a2),a0
46         jsr     WaitPort(a6)
47         lea     pr_MsgPort(a2),a0
48         jsr     GetMsg(a6)
49         move.l  d0,WBMsg
50
51 FromCLI:
52
53 ;       On réserve de la mémoire en CHIP-RAM pour les bitplanes,
54 ;       les sprites et la copper-list. (l'ami Thomas va etre heureux !)
55
56         move.l  ExecBase,a6
57         move.l  #$8000*4+256*8+32*2,d0
58         move.l  #$10002,d1      ; CHIP et CLEAR
59         jsr     AllocMem(a6)
60
61         move.l  d0,plan1                ; premier bitplan
62         beq     alerte          ; si pas de chip reservée !
63         add.l   #$8000,d0
64         move.l  d0,plan2                ; second bitplan
65         add.l   #$8000,d0
66         move.l  d0,SaveImage    ; zone de sauvegarde
67         add.l   #$10000,d0
68         move.l  d0,copper_list  ; copper-list
69         add.l   #256,d0
70         move.l  d0,SpriteCursor ; et les sprites
71         add.l   #256,d0
72         move.l  d0,SpriteVide
73         add.l   #256,d0
74         move.l  d0,SpriteSelect
75         add.l   #256,d0
76         move.l  d0,SpriteTableau
77         add.l   #1024,d0
78         move.l  d0,SpriteNombre
79
80         bsr     main            ; LA routine
81
82 ;       On rend la mémoire
83
84         move.l  ExecBase,a6
85         move.l  plan1,a1
86         move.l  #$8000*4+256*8+32*2,d0
87         jsr     FreeMem(a6)
88
89 EmergencyReturn:
90         move.l  WBMsg(pc),d0
91         beq.s   More
92         move.l  d0,a1
93         jsr     Forbid(a6)
94         jsr     ReplyMsg(a6)
95 More:
96         moveq   #0,d0
97         rts
98
99 WBMsg:  dc.l    0
100
101
102 alerte:
103         lea     IntuitionName(pc),a1
104         move.l  (ExecBase).w,a6
105         jsr     OldOpenLibrary(a6)
106         move.l  d0,a6
107
108         lea     TexteAlerte(pc),a0
109         moveq   #0,d0
110         move.l  #32,d1
111         jsr     DisplayAlert(a6)
112
113         move.l  a6,a1
114         move.l  (ExecBase).w,a6
115         jsr     CloseLibrary(a6)
116         bra     EmergencyReturn
117
118 TexteAlerte:
119         dc.b    0,32,18," Turmites meditation: pas assez de CHIP ! ",0,0
120         even
121
122
123 ;       ************************************************************
124 ;       ************************************************************
125 ;       *************  Voila le coeur du programme !!! *************
126 ;       ************************************************************
127 ;       ************************************************************
128
129 main:
130
131         bsr     save_all                ; sauve tout pour pouvoir revenir
132         bsr     Inits           ; initialise les registres hard
133
134         lea     TableAdan,a1    ; copie le tableau de la première turmite
135         bsr     BigStart
136         clr.w   FlagQuit
137
138 MainBoucle:
139
140         clr.w   VblFlag
141         bsr     turmites
142 synchro:
143         tst.w   VblFlag
144         beq     synchro
145
146         bsr     AfficheNombre   ; routine pour afficher le nombre de turmites
147         bsr     GetKey          ; routine de lecture clavier
148         tst.w   d0
149         bmi     pasdetouche
150         tst.b   d0              ; si appuie et pas relache, on ne fait rien
151         bmi     pasdetouche
152         and.w   #$7f,d0
153
154 ;       A               Nutrition automatique
155 ;       P               Pause
156 ;       I               Informations
157 ;       1-2-3-4         Changement de couleur de nourriture
158 ;       Q               Quitter
159 ;       R               Reset (repart avec turmite actuelle)
160 ;       F               Suivre la turmite sélectionnée
161 ;       T               Mode tuer
162 ;       S               Mode sélection
163 ;       M               Mémorise l'image actuelle
164 ;       f1-f2-f3-f4     Reconstruit terrain en blocs
165 ;       f5              Remplie le terrain
166 ;       f6              Ramène l'image sauvée
167
168         cmp.w   #$10,d0         ; "A"
169         bne     PasAuto
170         not.w   FlagAuto
171         eor.b   #2,$bfe001
172 PasAuto:
173
174         cmp.w   #$21,d0         ; "S"
175         bne     PasModeSelection
176         move.w  #-1,ModeDroite
177         move.l  SpriteCursor,a0
178         lea     ImageCursor,a1
179         bsr     InitSprites     ; copie les données bitmap du sprite 'selection'
180 PasModeSelection:
181
182         cmp.w   #$14,d0         ; "T"
183         bne     PasModeTuer
184         clr.w   ModeDroite
185         move.l  SpriteCursor,a0
186         lea     ImageTuer,a1
187         bsr     InitSprites     ; copie les données bitmap du sprite 'tuer'
188 PasModeTuer:
189
190         cmp.w   #$23,d0         ; "F"
191         bne     PasSuivre
192         not.w   FlagSuivre      ; commute le flag
193         bra     ApresKeys
194 PasSuivre:
195
196         cmp.w   #$55,d0         ; "f6"
197         bne     Pasf6
198         bsr     AfficheImage
199         bra     ApresKeys
200 Pasf6:
201
202         cmp.w   #$29,d0         ; "M"
203         bne     PasRameneImage
204         move.l  plan1,a0
205         move.l  SaveImage,a1
206         move.w  #16383,d0
207 RameneImage:
208         move.l  (a0)+,(a1)+
209         dbf     d0,RameneImage
210         bra     ApresKeys
211 PasRameneImage:
212
213         cmp.w   #$50,d0         ; "f1" à "f4"
214         bmi     Pasfx
215         cmp.w   #$54,d0
216         bpl     Pasfx
217         sub.w   #$50-5,d0
218         move.w  #1,d1
219         lsl.w   d0,d1
220         move.w  d1,d0
221         bsr     DrawWorld       ; redessine le terrain
222         bra     ApresKeys
223 Pasfx:
224
225         cmp.w   #$54,d0         ; "f5"
226         bne     Pasf5
227         bsr     ClearWorld      ; vide avec la couleur en cours
228         bra     ApresKeys
229 Pasf5:
230
231         cmp.b   #$19,d0         ; "P"
232         bne     PasPause
233         not.w   FlagPause       ; commute le flag
234         bra     ApresKeys
235 PasPause:
236
237         cmp.b   #$20,d0         ;"Q"
238         bne     PasQuit
239         move.w  #-1,FlagQuit    ; personnellement, je suis contre, mais
240         bra     ApresKeys       ; les meilleurs choses ont une fin...
241 PasQuit:
242
243         move.w  d0,d1           ; "1" à "4"
244         sub.w   #1,d1
245         bmi     PasColors
246         cmp.w   #4,d1
247         bpl     PasColors
248         move.w  d1,Color        ; change la couleur en cours
249         add.w   d1,d1
250         move.w  CouleursSouris(pc,d1.w),$dff180+18*2
251         bra     ApresKeys
252 CouleursSouris:
253         dc.w    $000,$f00,$00f,$ec0     ; noir, rouge, bleu, jaune.
254 PasColors:
255
256         cmp.w   #$17,d0         ; "I"
257         bne     PasAffiche
258         bsr     ClearTableau
259         not.w   FlagAffiche     ; commute le flag de l'affichage
260         tst.w   FlagAffiche
261         beq     ApresKeys
262         bsr     AfficheCerveau  ; si mode affiche
263         bra     ApresKeys
264 PasAffiche:
265
266         cmp.w   #$13,d0         ; "R"
267         bne     PasReset
268         tst.w   nombre
269         beq     ResetComplet    ; si toutes mortes, on repart du début
270         tst.l   AdrSelect
271         beq     PasReset
272         move.l  AdrSelect,a1
273         lea     Table(a1),a1
274         bsr     BigStart        ; reprend au début
275         bra     ApresKeys
276 ResetComplet:
277         lea     TableAdan,a1    ; copie le tableau de la première turmite
278         bsr     BigStart
279         bra     ApresKeys
280 PasReset:
281
282 ApresKeys:
283 pasdetouche:
284
285         tst.w   FlagAuto
286         beq     PasDejeuner
287         add.w   #1,CompteurFreq
288         cmp.w   #Frequence,CompteurFreq
289         bne     PasDejeuner
290         bsr     AfficheImage
291         clr.w   CompteurFreq
292 PasDejeuner:
293         
294
295         btst    #6,$bfe001      ; test de la touche gauche de la souris
296         bne     PasMouseKey
297         bsr     Paves           ; routine qui affiche la nourriture
298 PasMouseKey:
299
300         tst.w   FlagAffiche     ; le mode affichage y-est-il ?
301         beq     PasNouveau
302         move.l  AdrSelect,d0
303         cmp.l   PAdrSelect,d0   ; la turmite a-t-elle changé ?
304         beq     PasNouveau
305         move.l  AdrSelect,PAdrSelect    ; mémorise la nouvelle turmite
306         bsr     AfficheCerveau
307 PasNouveau:
308
309         tst.w   FlagQuit                ; veut-on quitter ?
310         beq     MainBoucle
311
312         and.b   #253,$bfe001
313         bsr     restore_all     ; remet tout en place
314         moveq   #0,d0           ; et revient
315         rts
316
317 VblFlag:        dc.w    0       ; flag de synchronisation VBL
318 ModeDroite:     dc.w    -1      ; role du bouton droit souris (select/tuer)
319 FlagAuto:       dc.w    0       ; flag pour la nutrition auto.
320 CompteurFreq:   dc.w    0       ; Compteur pour la nutrition
321 FlagPause:      dc.w    0       ; flag pour le mode pause
322 FlagSuivre:     dc.w    0       ; flag pour 'follow'
323 FlagQuit:       dc.w    0       ; flag pour quitter
324 FlagAffiche:    dc.w    0       ; flag pour l'affichage du tableau
325 PAdrSelect:     dc.l    0       ; turmite actuellement affichée
326 Color:          dc.w    2       ; couleur de la nourriture actuelle
327
328
329 ;       **********************************************************
330 ;       ********* Affichage du nombre de turmites à l'écran ******
331 ;       **********************************************************
332
333 AfficheNombre:
334         move.w  nombre,d0
335         lea     TableCarChiffres,a4     ; table des caractères numériques
336         divu    #10,d0          ; utilise le reste d'une division par 10
337         swap    d0
338         lsl.w   #4,d0
339         lea     (a4,d0.w),a1
340         clr.w   d0
341         swap    d0
342         divu    #10,d0
343         swap    d0
344         lsl.w   #4,d0
345         lea     (a4,d0.w),a2
346         clr.w   d0
347         swap    d0
348         divu    #10,d0
349         swap    d0
350         lsl.w   #4,d0
351         lea     (a4,d0.w),a3
352         clr.w   d0
353         swap    d0
354         divu    #10,d0
355         swap    d0
356         lsl.w   #4,d0
357         lea     (a4,d0.w),a4
358
359         move.l  SpriteNombre,a0         ; adresse des datas de ce sprite
360         lea     4(a0),a0                ; datas bitmap
361         move.w  #5,d0                   ; caractères de 6 lignes
362 BoucleAfficheNombre:            ; recopie les caractères de la table
363         move.w  (a4)+,d1                ; dans le sprite.
364         lsl.w   #5,d1
365         or.w    (a3)+,d1
366         move.w  d1,(a0)
367         clr.w   2(a0)
368         move.w  (a2)+,d1
369         lsl.w   #5,d1
370         or.w    (a1)+,d1
371         lsl.w   #6,d1
372         move.w  d1,32(a0)
373         clr.w   34(a0)
374         add.l   #4,a0
375         dbf     d0,BoucleAfficheNombre
376         rts
377
378
379 ;       **********************************************************
380 ;       *** Routine d'initialisation de la table des turmites ****
381 ;       **********************************************************
382
383 BigStart:
384         lea     DataTurmites,a0
385         lea     AdressesLibres,a5       ; constitue la table des adresses libres
386         move.w  #ntur-1,d0
387 RempliePile:
388         clr.w   V(a0)
389         move.l  a0,-(a5)
390         add.l   #ndatas,a0
391         dbf     d0,RempliePile
392
393         move.l  (a5)+,a0        ; initialise la première turmite
394         move.l  a5,SPtur
395         move.w  #255,X(a0)
396         move.w  #255,Y(a0)
397         move.w  #0,E(a0)
398         move.w  #0,O(a0)
399         move.w  #1,V(a0)
400         lea     Table(a0),a0
401         move.w  #(ndatas-Table)/2-1,d0
402 BoucleBigStart:
403         move.w  (a1)+,(a0)+
404         dbf     d0,BoucleBigStart
405
406         move.w  #256,d0
407         bsr     DrawWorld               ; affiche le décors avec un bloc central de 256
408
409         clr.l   AdrSelect       ; on vire la sélection et l'affichage
410         clr.w   FlagAffiche
411         bsr     ClearTableau
412
413         rts
414
415 ;       **********************************************************
416 ;       ******* Routine d'affichage des paves de nourriture ******
417 ;       **********************************************************
418
419 Paves:
420         move.w  Xmousew,d0      ; si on dépasse à droite alors on corrige
421         cmp.w   #498,d0
422         bmi     PasPavesDroite
423         move.w  #497,d0
424 PasPavesDroite:
425         move.w  d0,d4
426         and.w   #$0f,d4         ; masque pour le décalage
427         move.w  Ymousew,d1
428         cmp.w   #497,d1         ; test le dépassement en bas
429         bmi     PasPavesBas
430         move.w  #496,d1
431 PasPavesBas:
432                         ; calcul de l'adresse en mémoire vidéo
433         lsl.w   #6,d1           ; 64 octets par ligne (512 points)
434         lsr.w   #3,d0           ; on divise X par 8
435         and.w   #$fffe,d0       ; force une adresse paire
436         add.w   d1,d0           ; X+Y
437         move.l  plan1,a0        ; + base de la mémoire
438         lea     (a0,d0),a0
439         move.l  plan2,a1        ; idem plan 2
440         lea     (a1,d0),a1
441
442         move.l  #$ffff0000,d0   ; dessin du bloc
443         lsr.l   d4,d0           ; avec décalage
444         not.l   d0              ; et masque
445
446         move.w  Color,d1
447         clr.l   d2              ; dessin pour le plan 1
448         clr.l   d3              ; dessin pour le plan 2
449
450                 ; on modifie d2 et d3 en fonction des bits de la couleur
451         btst    #0,d1
452         beq     PasPlan0
453         move.l  d0,d2
454         not.l   d2
455 PasPlan0:
456         btst    #1,d1
457         beq     PasPlan1
458         move.l  d0,d3
459         not.l   d3
460 PasPlan1:
461
462         move.w  #15,d4  ; blocs de 16 lignes de haut
463 BouclePaves:
464         and.l   d0,(a0)
465         or.l    d2,(a0)
466         add.l   #64,a0
467         and.l   d0,(a1)
468         or.l    d3,(a1)
469         add.l   #64,a1
470         dbf     d4,BouclePaves
471 FinPaves:
472         rts
473
474 ;       **********************************************************
475 ;       *********** Routine d'affichage d'un 'Cerveau' ***********
476 ;       **********************************************************
477
478 AfficheCerveau:
479         movem.l d0-a6,-(sp)
480         tst.l   AdrSelect       ; y a-t-il une turmite sélectionnée ?
481         beq     PasCerveau              ; si non, alors ne rien faire
482
483         move.l  SpriteTableau,a0        ; sprite pour afficher le tableau
484         lea     4(a0),a0                ; adresse des données bitmap du sprite
485         move.l  AdrSelect,a1    ; adresse de la turmite sélectionnée
486         lea     Table(a1),a1    ; adresse de son tableau de comportement
487         move.w  #3,d0           ; 4 états
488 BoucleEtat:
489         move.w  #3,d1           ; et 4 couleurs par état
490 BoucleCouleur:
491         move.b  (a1)+,d3
492         add.b   #1,d3
493         ext.w   d3
494         lsl.w   #4,d3
495         lea     TableCarDirections,a2   ; table des caractères (g/a/d)
496         lea     (a2,d3.w),a2
497         move.b  (a1)+,d3
498         ext.w   d3
499         lsl.w   #4,d3
500         lea     TableCarEtats,a3                ; table des caractères états (A/B/C/D)
501         lea     (a3,d3.w),a3
502         move.b  (a1)+,d3
503         ext.w   d3
504         lsl.w   #4,d3
505         lea     TableCarChiffres,a4     ; chiffres (0/1/2/3...)
506         lea     (a4,d3.w),a4
507
508         move.w  #5,d2
509 BoucleCar:
510         moveq   #0,d3
511         or.w    (a2)+,d3
512         or.w    (a3)+,d3
513         or.w    (a4)+,d3
514         move.w  d3,(a0)+
515         clr.w   (a0)+
516         dbf     d2,BoucleCar
517         add.w   #256-24,a0
518         dbf     d1,BoucleCouleur
519         add.w   #28-256*4,a0
520         dbf     d0,BoucleEtat
521
522 PasCerveau:
523         movem.l (sp)+,d0-a6
524         rts
525
526 ClearTableau:           ; vide la bitmap du sprite tableau
527         movem.l d0/a0,-(sp)
528         move.l  SpriteTableau,a0
529         lea     4(a0),a0
530         move.w  #55,d0
531 BoucleClearTableau:
532         clr.w   256(a0)
533         clr.w   512(a0)
534         clr.w   768(a0)
535         clr.w   (a0)+
536         dbf     d0,BoucleClearTableau
537         movem.l (sp)+,d0/a0
538         rts
539
540 ;       **********************************************************
541 ;       **** Routine de gestion des déplacements des turmites ****
542 ;       **********************************************************
543
544 nombre: dc.w    0
545
546 turmites:
547         clr.w   nombre          ; vide le nombre
548         lea     DataTurmites,a0 ; tableau des turmites
549         move.l  SPtur,a5        ; pile des adresses libres
550         move.l  plan1,a4        ; base mémoire vidéo plan 1
551         move.l  plan2,a3        ; base mémoire vidéo plan 2
552         move.l  #ntur-1,d0      ; nombre de turmites
553 boucle:
554
555         tst.w   V(a0)           ; est-elle en vie ?
556         beq     finboucle               ; si non, sniff...
557
558         add.w   #1,nombre       ; une de plus en vie !
559
560         move.w  X(a0),d1
561         move.w  Y(a0),d2
562
563         move.w  Xmousew,d3      ; est-elle sous la souris ?
564         sub.w   d1,d3
565         bpl     PasAbs1
566         neg.w   d3
567 PasAbs1:
568         cmp.w   #8,d3
569         bpl     PasSousMouse
570
571         move.w  Ymousew,d3
572         sub.w   d2,d3
573         bpl     PasAbs2
574         neg.w   d3
575 PasAbs2:
576         cmp.w   #8,d3
577         bpl     PasSousMouse
578         btst    #10,$dff016     ; POTGOR
579         bne     PasSousMouse
580
581 ;                       elle est sous la souris
582
583         tst.w   ModeDroite
584         beq     ModeTuer
585 ModeSelection:          ; si mode sélection, mémorise son adresse
586         move.l  a0,AdrSelect
587         bra     PasSousMouse
588 ModeTuer:
589         clr.w   V(a0)           ; si mode tuer, on la desintègre
590         move.l  a0,-(a5)        ; nouvelle adresse libre dans la pile
591         cmp.l   AdrSelect,a0    ; si c'était elle qui était sélectionnée
592         bne     finboucle
593         clr.l   AdrSelect       ; elle ne l'est plus
594         clr.w   FlagSuivre      ; le mode follow dégage
595         clr.w   FlagAffiche     ; le tableau disparait
596         bsr     ClearTableau    ; il faut l'effacer
597         bra     finboucle
598 PasSousMouse:
599
600         tst.w   FlagPause       ; est-on en mode pause
601         bne     finboucle               ; si oui, on ne fait pas les mouvements
602
603         move.w  d1,d3           ; si non
604         lsl.w   #6,d2
605         lsr.w   #3,d3
606         add.w   d3,d2           ; d2 adr dans le bitplan
607         not.w   d1
608         and.w   #7,d1
609
610         moveq   #0,d3           ; d3 couleur de la case sous la turmite
611         btst    d1,(a4,d2.w)    ; on test les bits en mémoire vidéo
612         beq     bit0nul
613         or.w    #1,d3
614 bit0nul:
615         btst    d1,(a3,d2.w)
616         beq     bit1nul
617         or.w    #2,d3
618 bit1nul:
619         add.w   d3,V(a0)
620
621 ; calcul de l'adresse de la case dans le tableau de comportement
622
623         move.w  d3,d4           ; d3=d3*3 (pour la colonne, 3 octets par case)
624         add.w   d3,d3
625         add.w   d4,d3
626
627         move.w  E(a0),d4        ; d4=état*12 (pour la ligne, 12 octets par ligne)
628         add.w   d4,d4
629         add.w   d4,d4
630         add.w   d4,d3
631         add.w   d4,d4
632         add.w   d4,d3
633         move.w  d3,d4
634
635         lea     Table(a0,d4),a1
636         move.b  1(a1),E+1(a0)   ; nouvel état
637         move.b  0(a1),d3
638         add.b   d3,O+1(a0)
639         and.b   #3,O+1(a0)      ; nouvelle direction
640         moveq   #0,d3
641         move.b  2(a1),d3        ; couleur à mettre sous la turmite avant de partir
642
643 bit0d:                  ; le plot pour afficher la turmite
644         btst    #0,d3           ; surement optimisable...
645         beq     bit0dnul
646 bit0dnnul:
647         bset    d1,(a4,d2.w)
648         bra     bit1d
649 bit0dnul:
650         bclr    d1,(a4,d2.w)
651 bit1d:
652         btst    #1,d3
653         beq     bit1dnul
654 bit1dnnul:
655         bset    d1,(a3,d2.w)
656         bra     finbitd
657 bit1dnul:
658         bclr    d1,(a3,d2.w)
659 finbitd:
660
661 PasPlot:
662         sub.w   #1,V(a0)                ; elle se fatigue
663         sub.w   d3,V(a0)                ; et perd la valeur de ce qu'elle met sur la case
664         bgt     PasMorte                ; est-elle morte de fatigue ?
665 Morte:
666         clr.w   V(a0)           ; la vie est dure au pays des turmites
667         move.l  a0,-(a5)        ; nouvelle adresse libre dans la pile
668         cmp.l   AdrSelect,a0    ; si c'était elle qui était sélectionnée
669         bne     finboucle
670         clr.l   AdrSelect       ; elle ne l'est plus
671         clr.w   FlagSuivre      ; le mode follow dégage
672         clr.w   FlagAffiche     ; le tableau disparait
673         bsr     ClearTableau    ; il faut l'effacer
674         bra     finboucle
675 PasMorte:
676         move.w  O(a0),d1        ; sinon, mouvement
677         btst    #0,d1
678         bne     DeplaceHoriz
679
680 DeplaceVert:
681         btst    #1,d1
682         bne     Monte
683         add.w   #1,Y(a0)
684         and.w   #511,Y(a0)      ; limite à 512 points en hauteur
685         bra     FinDeplace
686 Monte:
687         sub.w   #1,Y(a0)
688         and.w   #511,Y(a0)
689         bra     FinDeplace
690
691 DeplaceHoriz:
692         btst    #1,d1
693         bne     Gauche
694         add.w   #1,X(a0)
695         and.w   #511,X(a0)      ; limite à 512 points en largeur
696         bra     FinDeplace
697 Gauche:
698         sub.w   #1,X(a0)
699         and.w   #511,X(a0)
700
701 FinDeplace:
702         cmp.w   #128,V(a0)      ; a-t-elle suffisament d'énergie pour se reproduire ?
703         bmi     finboucle               ; non
704 Duplique:
705         lsr.w   V(a0)           ; elle perd de l'énergie
706         cmp.l   #AdressesLibres,a5              ; y-a-t-il de la place ?
707         beq     finboucle                       ; non...
708
709         move.l  (a5),a1
710
711         move.l  a0,a2
712         rept    ndatas/2        ; recopie son tableau dans son descendant
713         move.w  (a2)+,(a1)+
714         endr
715
716         move.l  (a5)+,a2
717
718 ;               **** Mutations ****
719
720         move.w  #3,d6
721 aleatoire:
722                 ; d3 et d4 = random(256)
723
724         move.w  CompteurRnd,d4
725         add.l   #$87654321,d4
726         move.l  d4,d5
727         add.l   d5,d5
728         add.l   d5,d4
729         move.l  d4,CompteurRnd
730
731         move.w  CompteurRnd,d3
732         add.l   #$87654321,d3
733         move.l  d3,d5
734         add.l   d5,d5
735         add.l   d5,d3
736         move.l  d3,CompteurRnd
737
738         move.w  d4,d5
739         lsr.w   #2,d5
740         and.w   #15,d5  ; 16 cases possibles dans le tableau
741         move.w  d5,d1   ; *3 car 3 octets par case
742         add.w   d5,d5
743         add.w   d1,d5
744         lea     Table(a2,d5.w),a1
745
746         and.w   #3,d4
747         cmp.w   #1,d4   ; modifie-t-on la direction ?
748         bne     PasDir  ; si non...
749 ChercheRnd3:
750         move.w  CompteurRnd,d3
751         add.l   #$87654321,d3
752         move.l  d3,d5
753         add.l   d5,d5
754         add.l   d5,d3
755         move.l  d3,CompteurRnd
756         and.w   #3,d3
757         cmp.w   #3,d3
758         beq     ChercheRnd3
759         move.b  rnd3(pc,d3),0(a1)
760         bra     finaleatoire
761 rnd3:   dc.b    -1,0,1,0
762 PasDir:
763         and.w   #3,d3   ; modifie-t-on l'état ?
764         cmp.w   #2,d4   ; si non...
765         bne     PasEta
766         move.b  d3,1(a1)
767         bra     finaleatoire
768 PasEta:
769         cmp.w   #3,d4   ; modifie-t-on la couleur ?
770         bne     aleatoire       ; si non, on revient au début
771         move.b  d3,2(a1)
772 finaleatoire:
773         dbf     d6,aleatoire    ; et on fait ça 4 fois
774
775 finboucle:
776
777         add.l   #ndatas,a0      ; turmite suivante
778         dbf     d0,boucle
779         move.l  a5,SPtur        ; sauve le nouveau pointeur
780         rts
781
782 CompteurRnd:    dc.l    0
783 AdrSelect:      dc.l    0
784
785 ;       ******************************************************
786 ;       *********** Routine de traçage du terrain ************
787 ;       ******************************************************
788
789 ;       D0=Largeur du coté (32/64/128/256)
790
791 DrawWorld:
792         movem.l d0-a6,-(sp)
793
794         move.l  plan1,a0        ; bases des bitplanes
795         move.l  plan2,a1
796         moveq   #0,d1
797         moveq   #0,d2
798         move.w  #$1fff,d3       ; tout d'abord, on efface
799 ClearScreen:
800         move.l  d1,(a0)+
801         move.l  d2,(a1)+
802         dbf     d3,ClearScreen
803
804         move.w  d0,d1           ; calcul de l'adresse de début, on passe
805         move.w  d0,d2           ; des octets pour la marge de gauche.
806         lsl.w   #5,d1
807         lsr.w   #4,d2
808         add.w   d2,d1
809         move.l  plan1,a0
810         move.l  plan2,a1
811         add.w   d1,a0
812         add.w   d1,a1
813
814         bsr     ChoixBits               ; voire ci-dessous
815
816         move.l  #512,d3         ; combien de carrés ?
817         divu    d0,d3           ; un DIVU ne peut pas faire de mal
818         lsr.w   #1,d3           ; (enfin, pas trop de mal...)
819         sub.w   #1,d3
820         move.w  d3,a2
821
822         move.w  d0,d3
823         sub.w   #1,d3
824         move.w  d3,a3
825
826         move.w  d0,d6
827         lsr.w   #4,d6
828         sub.w   #1,d6
829         lsl.w   #6,d0
830
831         move.w  a2,d4           ; boucle verticale des carrés
832 DWboucleV:
833         move.w  a2,d5           ; idem horizontale
834 DWboucleH:
835
836         move.w  a3,d3           ; les boucles pour UN carré
837 DWpetiteboucleV:
838         move.w  d6,d7
839 DWpetiteboucleHfill:
840         move.w  d1,(a0)+
841         move.w  d2,(a1)+
842         dbf     d7,DWpetiteboucleHfill
843         move.w  d6,d7
844 DWpetiteboucleHclear:
845         clr.w   (a0)+
846         clr.w   (a1)+
847         dbf     d7,DWpetiteboucleHclear
848         dbf     d3,DWpetiteboucleV
849
850         dbf     d5,DWboucleH
851         add.w   d0,a0
852         add.w   d0,a1
853         dbf     d4,DWboucleV
854         movem.l (sp)+,d0-a6
855         rts
856
857
858 ClearWorld:             ; remplie l'écran avec la couleur en cours
859         movem.l d0-a6,-(sp)
860         move.l  plan1,a0
861         move.l  plan2,a1
862         bsr     ChoixBits
863         move.w  #$3fff,d3
864 ClearScreen2:
865         move.w  d1,(a0)+
866         move.w  d2,(a1)+
867         dbf     d3,ClearScreen2
868         movem.l (sp)+,d0-a6
869         rts
870
871
872
873 AfficheImage:
874         move.l  SaveImage,a0
875         move.l  plan1,a1
876         move.w  #16383,d0
877 SauveImage:
878         move.l  (a0)+,(a1)+
879         dbf     d0,SauveImage
880         rts
881
882
883 ChoixBits:              ; la routine qui détermine les mots en
884         moveq   #0,d1           ; fonction des bits de la couleur
885         moveq   #0,d2
886         move.w  Color,d3
887         btst    #0,d3
888         beq     PasCls0
889         move.w  #-1,d1
890 PasCls0:
891         btst    #1,d3
892         beq     PasCls1
893         move.w  #-1,d2
894 PasCls1:
895         rts
896
897
898 ;       ******************************************************
899 ;       ******************* Initialisations ******************
900 ;       ******************************************************
901
902 Inits:
903         lea     $dff000,a6
904
905         move.w  #$7fff,$9a(a6)          ; INTENA
906         move.w  #$7fff,$96(a6)          ; DMACON
907         move.w  #$c020,$9a(a6)          ; IT vbl uniquement
908         move.w  #$83a0,$96(a6)          ; copper et bitplan
909
910         move.l  SpriteVide,a0
911         clr.l   (a0)+
912         clr.l   (a0)+
913
914         move.l  SpriteTableau,a0        ; positionne les sprites
915         move.w  #$2e50,(a0)
916         move.w  #$4a00,2(a0)
917         move.w  #$2e58,256(a0)
918         move.w  #$4a00,256+2(a0)
919         move.w  #$2e60,512(a0)
920         move.w  #$4a00,512+2(a0)
921         move.w  #$2e68,768(a0)
922         move.w  #$4a00,768+2(a0)
923
924         move.l  SpriteNombre,a0
925         move.w  #$2ec2,(a0)
926         move.w  #$3400,2(a0)
927         move.w  #$2eca,32(a0)
928         move.w  #$3400,34(a0)
929
930         move.l  SpriteCursor,a0
931         lea     ImageCursor,a1
932         bsr     InitSprites
933         move.l  SpriteSelect,a0
934         lea     ImageSelect,a1
935         bsr     InitSprites
936
937         move.l  copper_list,a0
938
939         move.l  #$00e00000,(a0)+        ; la copper-list met les pointeurs
940         move.l  #$00e20000,(a0)+        ; bitplanes
941         move.l  #$00e40000,(a0)+
942         move.l  #$00e60000,(a0)+
943         move.l  #$01020000,(a0)+
944         move.l  #$fffffffe,(a0)+
945
946 ; On se met en 256*256 2 bitplanes (4 couleurs) avec 16 points cachés
947 ; sur la gauche pour pouvoir faire un scrolling avec le delay.
948
949         move.l  copper_list,$80(a6)     ; COP1LC
950         clr.w   $88(a6)                 ; COPJMP1
951         move.l  #$2ca12ca1,$8e(a6)      ; DIWSTRT et DIWSTOP
952         move.w  #$2200,$100(a6)         ; BPLCON0
953         clr.l   $102(a6)                        ; BPLCON1 et BPLCON2
954         move.w  #30,$108(a6)            ; BPLMOD1
955         move.w  #30,$10a(a6)            ; BPLMOD2
956         move.l  #$004000c0,$92(a6)      ; DDFSTRT et DDFSTOP
957
958         move.l  #irq,$6c                ; vecteur irq
959
960         move.w  #$0024,$dff104          ; priorité des sprites
961         move.w  #$555,$dff180+17*2      ; couleurs de ces meme sprites
962         move.w  #$00f,$dff180+18*2
963         move.w  #$fff,$dff180+19*2
964         move.w  #$fff,$dff180+21*2
965         move.w  #$fff,$dff180+25*2
966         move.w  #$fff,$dff180+29*2
967
968         clr.w   $dff180                 ; couleur playfield
969         move.w  #$f00,$dff182           ; noir, rouge, bleu, jaune
970         move.w  #$00f,$dff184
971         move.w  #$ec0,$dff186
972         bsr     InitClavier             ; initialise le clavier
973
974         rts
975
976 InitSprites
977         move.w  #15,d0
978         clr.l   (a0)+
979 RecopieSprites:
980         move.l  (a1)+,(a0)+
981         dbf     d0,RecopieSprites
982         clr.l   (a0)+
983         rts
984
985 ;       ********************************************************
986 ;       ******************* Gestion de la souris ***************
987 ;       ********************************************************
988
989 Souris:
990         move.b  $dff00a,d1      ; abscisse souris (absolue) JOY0DAT
991         move.b  d1,d3
992         move.b  $dff00b,d0      ; ordonnée souris (absolue) JOY0DAT
993         move.b  d0,d2
994
995         sub.b   PrecXmouse,d0   ; - précédente abscisse= déplacement relatif
996         cmp.b   #127,d0         ; > 127, c'est que l'on a fait un tour complet
997         bmi     OkXmouse
998         add.b   #255,d0         ; on corrige
999 OkXmouse:
1000
1001         sub.b   PrecYmouse,d1   ; idem pour l'ordonnée
1002         cmp.b   #127,d1
1003         bmi     OkYmouse
1004         add.b   #255,d1
1005 OkYmouse:
1006
1007         ext.w   d0              ; passage en .W (relatif, peut etre négatif)
1008         ext.w   d1
1009         move.b  d3,PrecYmouse   ; nouvelle coordonnées absolues du système
1010         move.b  d2,PrecXmouse
1011         add.w   d0,Xmouse       ; ajoute le mouvement relatif aux coordonnées du
1012         add.w   d1,Ymouse       ; programme (qui sont absolues)
1013
1014         cmp.w   #255,Xmouse     ; dépasse-t-on à droite ?
1015         bmi     PasMouseDroite
1016         move.w  Xmouse,d0       ; si oui, on déplace la fenetre
1017         move.w  #255,Xmouse     ; et on remet la valeur maximum
1018         sub.w   #255,d0
1019         add.w   d0,Xwindow
1020         bra     PasMouseGauche
1021 PasMouseDroite:
1022         tst.w   Xmouse          ; dépasse-t-on à gauche ?
1023         bpl     PasMouseGauche
1024         move.w  Xmouse,d0       ; si oui, on déplace aussi la fenetre
1025         clr.w   Xmouse          ; et on met la valeur minimum
1026         add.w   d0,Xwindow
1027 PasMouseGauche:
1028         cmp.w   #255,Ymouse     ; idem pour Y
1029         bmi     PasMouseBas
1030         move.w  Ymouse,d0
1031         move.w  #255,Ymouse
1032         sub.w   #255,d0
1033         add.w   d0,Ywindow
1034         bra     PasMouseHaut
1035 PasMouseBas:
1036         tst.w   Ymouse
1037         bpl     PasMouseHaut
1038         move.w  Ymouse,d0
1039         clr.w   Ymouse
1040         add.w   d0,Ywindow
1041 PasMouseHaut:
1042
1043         move.w  Xmouse,d0
1044         move.w  Ymouse,d1
1045         add.w   #$a0,d0         ; coordonnées translatées dans le cadre écran
1046         add.w   #$2c,d1
1047
1048         move.w  d1,d2
1049         add.w   #8,d2           ; Y du bas du sprite
1050
1051         move.w  d0,d3           ; calcul des deux mots de controle en fonction
1052         lsr.w   #1,d3           ; de HSTART, VSTART et VSTOP
1053         move.w  d1,d4
1054         lsl.w   #8,d4
1055         move.b  d3,d4
1056
1057         move.b  d2,d5
1058         lsl.w   #8,d5
1059         roxl.w  #8,d1
1060         roxl.b  #1,d5
1061         roxl.w  #8,d2
1062         roxl.b  #1,d5
1063         roxr.b  #1,d0
1064         roxl.b  #1,d5
1065
1066         move.l  SpriteCursor,a0 ; met en place les deux mots de controle
1067         move.w  d4,(a0)+
1068         move.w  d5,(a0)
1069
1070         rts
1071
1072 ImageCursor:
1073         dc.w    $ff00,$fe00     ; une petit flèche 8*8
1074         dc.w    $8200,$fc00
1075         dc.w    $8400,$f800
1076         dc.w    $8800,$f000
1077         dc.w    $9000,$e000
1078         dc.w    $a000,$c000
1079         dc.w    $c000,$8000
1080         dc.w    $8000,$0000
1081 ImageTuer:
1082         dc.w    $ff00,$ff00     ; un petit carré 8*8
1083         dc.w    $8100,$fe00
1084         dc.w    $bd00,$c200
1085         dc.w    $a500,$c600
1086         dc.w    $a500,$c600
1087         dc.w    $bd00,$de00
1088         dc.w    $8100,$fe00
1089         dc.w    $ff00,$8000
1090 ImageSelect:
1091         dc.w    $d800,$d800     ; une petite mire 8*8
1092         dc.w    $8800,$8800
1093         dc.w    $0000,$0000
1094         dc.w    $8800,$8800
1095         dc.w    $d800,$d800
1096         dc.w    $0000,$0000
1097         dc.w    $0000,$0000
1098         dc.w    $0000,$0000
1099
1100 Xmouse:         dc.w    256
1101 Ymouse:         dc.w    256
1102 PrecXmouse:     dc.w    0
1103 PrecYmouse:     dc.w    0
1104 Xwindow:        dc.w    128
1105 Ywindow:        dc.w    128
1106 Xmousew:        dc.w    384
1107 Ymousew:        dc.w    384
1108
1109 ;       ******************************************************
1110 ;       ***************  Routine du 'scrolling' **************
1111 ;       ******************************************************
1112
1113 Screen:
1114         tst.w   FlagSuivre      ; est-on-en mode suivie automatique ?
1115         beq     PasSuivie               ; non
1116         tst.l   AdrSelect       ; une turmite est-elle sélectionnée ?
1117         beq     PasSuivie               ; non
1118         move.l  AdrSelect,a0    ; si oui
1119         tst.w   V(a0)           ; est-elle vivante ?
1120         beq     PasSuivie               ; non
1121 PasFinSuivre:
1122         move.w  X(a0),d0        ; prend ses coordonnées
1123         sub.w   #128,d0         ; centre
1124         move.w  d0,Xwindow      ; et les met dans celles de la fenetre
1125         move.w  Y(a0),d0
1126         sub.w   #128,d0
1127         move.w  d0,Ywindow
1128 PasSuivie:
1129
1130         move.w  Xwindow,d0      ; on corrige éventuellement les
1131         bpl     PasWindowGauche ; coordonnées de la fenetre
1132         moveq   #0,d0
1133         move.w  d0,Xwindow
1134         bra     PasWindowDroite
1135 PasWindowGauche:
1136         cmp.w   #256,d0
1137         bmi     PasWindowDroite
1138         move.w  #256,d0
1139         move.w  d0,Xwindow
1140 PasWindowDroite:
1141         move.w  Ywindow,d1
1142         bpl     PasWindowHaut
1143         moveq   #0,d1
1144         move.w  d1,Ywindow
1145         bra     PasWindowBas
1146 PasWindowHaut:
1147         cmp.w   #256,d1
1148         bmi     PasWindowBas
1149         move.w  #256,d1
1150         move.w  d1,Ywindow
1151 PasWindowBas:
1152
1153         move.w  Xmouse,Xmousew  ; coordonnées absolues de la souris dans
1154         add.w   d0,Xmousew      ; le terrain
1155         move.w  Ymouse,Ymousew
1156         add.w   d1,Ymousew
1157
1158         lsl.w   #6,d1           ; calcule de l'adresse de départ des bitplanes
1159         move.w  d0,d2
1160         lsr.w   #3,d2
1161         and.w   #$fffe,d2
1162         add.w   d2,d1
1163         not.w   d0
1164         and.w   #15,d0
1165         moveq   #0,d2
1166         move.w  d0,d2
1167         lsl.w   #4,d0
1168         or.w    d0,d2
1169
1170         move.l  copper_list,a1  ; met le delay dans la copper-list
1171         move.w  d2,2+16(a1)
1172
1173         move.l  plan1,a0
1174         add.w   d1,a0
1175         move.l  a0,d0
1176
1177         move.w  d0,6(a1)        ; met l'adresse dans la copper-list
1178         swap    d0
1179         move.w  d0,2(a1)
1180         swap    d0
1181
1182         add.l   #$8000,d0       ; deuxième bitplan
1183         move.w  d0,6+8(a1)
1184         swap    d0
1185         move.w  d0,2+8(a1)
1186
1187         moveq   #0,d4           ; gestion du sprite curseur de sélection
1188         moveq   #0,d5
1189         move.l  AdrSelect,d0
1190         beq     PasSpriteSelection
1191         move.l  d0,a0
1192         tst.w   V(a0)
1193         beq     PasSpriteSelection
1194         move.w  X(a0),d0
1195         sub.w   Xwindow,d0
1196         bmi     PasSpriteSelection
1197         cmp.w   #255,d0
1198         bpl     PasSpriteSelection
1199         move.w  Y(a0),d1
1200         sub.w   Ywindow,d1
1201         bmi     PasSpriteSelection
1202         cmp.w   #255,d1
1203         bpl     PasSpriteSelection
1204
1205         add.w   #$9d,d0         ; pareil que pour celui de la souris
1206         add.w   #$2a,d1
1207
1208         move.w  d1,d2
1209         add.w   #8,d2
1210
1211         move.w  d0,d3
1212         lsr.w   #1,d3
1213         move.w  d1,d4
1214         lsl.w   #8,d4
1215         move.b  d3,d4
1216
1217         move.b  d2,d5
1218         lsl.w   #8,d5
1219         roxl.w  #8,d1
1220         roxl.b  #1,d5
1221         roxl.w  #8,d2
1222         roxl.b  #1,d5
1223         roxr.b  #1,d0
1224         roxl.b  #1,d5
1225
1226 PasSpriteSelection:
1227         move.l  SpriteSelect,a0
1228         move.w  d4,(a0)+
1229         move.w  d5,(a0)
1230
1231         rts
1232
1233
1234 ;       ******************************************************
1235 ;       ****************** Routines de l'IRQ *****************
1236 ;       ******************************************************
1237
1238 irq:
1239         movem.l d0-a6,-(sp)
1240         bsr     GereSprites
1241         bsr     Souris
1242         bsr     Screen
1243         move.w  #-1,VblFlag
1244         movem.l (sp)+,d0-a6
1245         move.w  #$20,$dff09c            ; it vbl traitée INTREQ
1246         rte
1247
1248 ;       ******************************************************
1249 ;       ***** Routine de gestion des sprites (début VBL) *****
1250 ;       ******************************************************
1251
1252 GereSprites:
1253         move.l  SpriteCursor,$dff120    ; SPR0PT
1254         move.l  SpriteSelect,$dff124    ; SPR1PT
1255         move.l  SpriteNombre,d0
1256         move.l  d0,$dff128              ; SPR2PT
1257         add.l   #32,d0
1258         move.l  d0,$dff12c              ; SPR3PT
1259         move.l  SpriteTableau,d0        ; 4 sprites pour le tableau
1260         move.l  d0,$dff130              ; SPR4PT
1261         add.l   #256,d0
1262         move.l  d0,$dff134              ; SPR5PT
1263         add.l   #256,d0
1264         move.l  d0,$dff138              ; SPR6PT
1265         add.l   #256,d0
1266         move.l  d0,$dff13c              ; SPR7PT
1267         rts
1268
1269 ;       ******************************************************
1270 ;       **************** Routines du clavier *****************
1271 ;       ******************************************************
1272
1273 InitClavier:
1274         clr.w   PointeurClavierRead     ; vide les pointeurs du tampon
1275         move.w  #1,PointeurClavierWrite
1276         lea     ItClavier(pc),a0                ; en PC-relatif !
1277         move.l  a0,$68                  ; vecteur niveau 2 (clavier)
1278         move.b  #%10001000,$bfed01      ; ICR, bit SP (fin de transfert série)
1279         move.w  #$8008,$dff09a          ; INTENA (IT CIA-A)
1280         rts
1281
1282 ItClavier:
1283         movem.l a0/d0/d1,-(sp)
1284         move.w  $dff01e,d0              ; INTREQ (read: IT CIA-A ?)
1285         btst    #3,d0
1286         beq     FinItClavier
1287
1288         move.b  $bfed01,d0
1289         btst    #3,d0                   ; pas clavier
1290         beq     PasClavier
1291         move.w  PointeurClavierWrite,d1
1292         moveq   #0,d0
1293         move.b  $bfec01,d0
1294         or.b    #$40,$bfee01
1295         not.b   d0
1296         ror.b   #1,d0
1297         add.b   #1,d1
1298         cmp.w   PointeurClavierRead,d1
1299         beq     TamponClavierSature
1300         lea     TamponClavier(pc),a0
1301         move.b  d0,(a0,d1.w)
1302         move.w  d1,PointeurClavierWrite
1303 TamponClavierSature:
1304         and.b   #$bf,$bfee01
1305 PasClavier:
1306         move.w  #$0008,$dff09c          ; INTREQ (IT traitée)
1307 FinItClavier:
1308         movem.l (sp)+,a0/d0/d1
1309         rte
1310
1311 GetKey:
1312         moveq   #0,d0
1313         move.l  d1,-(sp)
1314         move.w  PointeurClavierRead,d1  ; pointeur relatif sur le tampon
1315         add.b   #1,d1                   ; touche suivante
1316         cmp.w   PointeurClavierWrite,d1 ; a-t-on vidé le tampon ?
1317         beq     NoKey
1318         move.b  TamponClavier(pc,d1.w),d0       ; si non, on remet le code
1319         move.w  d1,PointeurClavierRead  ; sauve le pointeur
1320         move.l  (sp)+,d1                ; et on revient
1321         rts
1322 NoKey:
1323         not.w   d0                      ; code d'erreur -1
1324         move.l  (sp)+,d1
1325         rts
1326
1327 PointeurClavierRead:    dc.w    0
1328 PointeurClavierWrite:   dc.w    0
1329 TamponClavier:          ds.b    256
1330
1331
1332 save_all:
1333         move.b  #%10000111,$bfd100
1334         move.l  4,a6
1335         jsr     -132(a6)
1336         move.l  $68,save_vecteur_kbd
1337         move.l  $6c,save_vecteur_irq
1338         move.w  $dff01c,save_intena     ; INTENA (read)
1339         or.w    #$c000,save_intena
1340         move.w  $dff002,save_dmacon     ; DMACON (read)
1341         or.w    #$8100,save_dmacon
1342         rts
1343
1344 restore_all:
1345         move.w  #$7fff,$dff09a          ; INTENA (write: clear all)
1346         move.w  #$7fff,$dff096          ; DMACON (write: clear all)
1347         move.l  save_vecteur_kbd,$68    ; vecteur IT clavier
1348         move.l  save_vecteur_irq,$6c    ; vecteur IT vbl
1349         move.w  save_intena,$dff09a     ; INTENA (write: remet les bits)
1350         move.w  save_dmacon,$dff096     ; DMACON (write: remet les bits)
1351         move.l  4,a6
1352         lea     GraphicName,a1
1353         jsr     OldOpenLibrary(a6)
1354         move.l  d0,a0
1355         move.l  38(a0),$dff080          ; COP1LC
1356         clr.w   $dff088                 ; COPJMP1
1357         move.l  d0,a1
1358         jsr     CloseLibrary(a6)
1359         rts
1360
1361 save_intena:    dc.w    0
1362 save_dmacon:    dc.w    0
1363 save_vecteur_irq:       dc.l    0
1364 save_vecteur_kbd:       dc.l    0
1365
1366 GraphicName:    dc.b    "graphics.library",0
1367 DosName:        dc.b    "dos.library",0
1368 IntuitionName:  dc.b    "intuition.library",0
1369
1370         even
1371
1372 ;       Table des caractères
1373
1374 TableCarDirections:
1375         dc.w    $0000,$0400,$0C00,$1C00,$0C00,$0400,0,0
1376         dc.w    $0000,$1800,$1800,$1800,$1800,$1800,0,0
1377         dc.w    $0000,$2000,$3000,$3800,$3000,$2000,0,0
1378 TableCarEtats:
1379         dc.w    $00C0,$0120,$0120,$01E0,$0120,$0120,0,0
1380         dc.w    $01C0,$0120,$01C0,$0120,$0120,$01C0,0,0
1381         dc.w    $00E0,$0100,$0100,$0100,$0100,$00E0,0,0
1382         dc.w    $01C0,$0120,$0120,$0120,$0120,$01C0,0,0
1383 TableCarChiffres:
1384         dc.w    $0006,$0009,$0009,$0009,$0009,$0006,0,0
1385         dc.w    $0002,$0006,$000A,$0002,$0002,$0002,0,0
1386         dc.w    $0006,$0009,$0001,$0002,$0004,$000F,0,0
1387         dc.w    $0006,$0009,$0002,$0001,$0009,$0006,0,0
1388         dc.w    $0008,$0008,$000A,$000F,$0002,$0002,0,0
1389         dc.w    $000F,$0008,$000E,$0001,$0001,$000E,0,0
1390         dc.w    $0007,$0008,$000E,$0009,$0009,$0006,0,0
1391         dc.w    $000F,$0001,$0001,$0002,$0002,$0002,0,0
1392         dc.w    $0006,$0009,$0006,$0009,$0009,$0006,0,0
1393         dc.w    $0006,$0009,$0009,$0007,$0001,$000E,0,0
1394
1395 A       equ     0
1396 B       equ     1
1397 C       equ     2
1398 D       equ     3
1399
1400 g       equ     -1
1401 a       equ     0
1402 d       equ     1
1403
1404 ;       turmite de départ
1405
1406 TableAdan:
1407         dc.b    d,B,1,a,A,0,a,B,0,a,B,0
1408         dc.b    a,B,0,a,A,0,d,C,0,a,A,0
1409         dc.b    a,B,0,a,A,0,a,D,0,a,A,0
1410         dc.b    a,B,0,a,A,0,g,A,0,a,A,0
1411
1412 Copyrights:
1413         dc.b    " Ecrit par F.Fleuret, Novembre 1989 "  ; je suis toujours possessif
1414
1415         section data1,bss
1416 startbss:
1417         ds.l    ntur            ; Pile des adresses libres
1418 AdressesLibres:
1419 SPtur:  ds.l    1
1420 plan1:          ds.l    1               ; pointeurs pour la CHIP-RAM réservée
1421 plan2:          ds.l    1               ;  Le Devpac se plante (et si !) si il
1422 SaveImage:      ds.l    1               ; y a des DC.x dans le segment BSS
1423 copper_list:    ds.l    1
1424 SpriteCursor:   ds.l    1
1425 SpriteSelect:   ds.l    1
1426 SpriteTableau:  ds.l    1
1427 SpriteVide:     ds.l    1
1428 SpriteNombre:   ds.l    1
1429
1430         section data2,bss
1431
1432 DataTurmites:
1433         ds.w    ndatas/2*ntur
1434
1435         end