-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path+B.s
2949 lines (2789 loc) · 66.8 KB
/
+B.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; ______________________________________________________________________________
; ..............................................................................
; ...................................................................2222222....
; ................................................................22222222220...
; ...................................................222........222222.....222..
; ..............................................2202222222222..22000............
; ..................................22000.....20222222222200000200002...........
; .................................2002202...2222200222.220000000200000000022...
; ....................220002......22222200..2200002.......2200000...20000000000.
; ....................22222202....2220000022200000..........200002........200000
; .....200000.........2222200000222200220000000002..........200002........20000.
; .....00222202........2220022000000002200002000002........2000002000020000000..
; ....2222200000.......220002200000002.2000000000000222222000000..2000000002....
; ....220000200002......20000..200002..220000200000000000000002.......22........
; ...2220002.220000 2....220002...22.....200002..0000000000002...................
; ...220000..222000002...20000..........200000......2222........................
; ...000000000000000000..200000..........00002..................................
; ..220000000022020000002.200002.........22.......______________________________
; ..0000002........2000000220022.................|
; .200000............2002........................| AMOSPro Version 2
; .200002........................................| Loader general
; 220002.........................................|______________________________
; ______________________________________________________________________________
;
Include "+AMOS_Includes.s"
Include "+Version.s"
; ______________________________________________________________________________
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; ROUTINES DE FIN / ROUTINES INTERNES
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION "E",CODE
; - - - - - - - - - - - - -
jmp Cold_Start
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; FIN DE L'INITIALISATION
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Init_Fin
; - - - - - - - - - - - - -
; Ouvre une structure programme
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
move.l PI_DefSize(a5),d0 Structure programme
JJsr L_Prg_NewStructure
move.l d0,a6
beq TheEnd_OOMem
; Charge AUTOEXEC.AMOS ou le programme voulu
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
moveq #-2,d0 Pas d'ecran de fond
JJsr L_Prg_New
moveq #-1,d0 Toujours adapter
JJsr L_Prg_Load
bne .NoProg
moveq #-1,d0 Semi Init Graphique
lea RunErr_RunOnly,a1 En cas d'erreur
sub.l a2,a2
JJsr L_Prg_RunIt Revient si out of memory!
; Pas de programme: on se branche à l'editeur
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.NoProg jsr Sys_VerInstall Verification de l'installation
beq TheEnd_Install
jsr Edit_Load Charge l'editeur
bne.s TheEnd_Editor
moveq #-1,d0 DefRun normal
JJsr L_Prg_New
moveq #-1,d0 Titre
JJsr L_Ed_Cold
bne.s TheEnd_Editor
jsr WOption Affiche ou non!
JJsr L_Ed_Title Le titre
JJmp L_Ed_Loop Branche à la boucle
; Message d'erreur panique residents
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TheEnd_Editor
lea Panic_Editor(pc),a0 Cannot load editor
bra TheEndMm
TheEnd_OOMem
lea Panic_OOMem(pc),a0 Out of memory
bra TheEndMm
TheEnd_Install
lea Panic_Install(pc),a0
bra TheEndMm
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; SORTIE GENERALE
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TheEndMm
move.l a0,Panic
TheEnd
tst.b Sys_LibStarted(a5)
beq .Nolib
; Les librairies sont demarrees
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lea Sys_EndRoutines(a5),a1 Les routines ajoutees
SyCall CallRoutines
JJsr L_CloAll Fichiers, imprimante
JJsr L_PRT_Close
JJsr L_Equ_Free
JJsr L_Includes_Clear Les includes du dernier programme
tst.l Edit_Segment(a5) Arrete l'editeur
beq.s .NEd
JJsr L_Ed_End
.NEd
move.l Edt_List(a5),d1 Les structures EDT restantes
beq.s .EdtX en cas de KILL editor
.ExtL move.l d1,a1
move.l Edt_Next(a1),d1
move.l #Edt_Long,d0
SyCall MemFree
tst.l d1
bne.s .ExtL
.EdtX move.l Prg_List(a5),d0 Les structure PRG restantes
beq.s .PrgX
.PrgL move.l d0,a6
JJsr L_Prg_DelStructure
move.l Prg_List(a5),d0
bne.s .PrgL
.PrgX
bsr Edit_Free Enleve l'editeur
bsr Mon_Free Enleve le moniteur + banque
bsr EffFSel Enleve la resource file selector
bsr EffMouse Enleve la souris
JJsr L_WB_Open Ouvre le WB en fond
bsr Libraries_Stop STOP les librairies
.Nolib
; Partie non dependantes des librairies
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bsr D_Close Ferme le dernier fichier...
tst.b Sys_WStarted(a5) Arrete W.Lib
beq.s .Skip0
move.l Sys_WAd(a5),a0
jsr 4(a0)
.Skip0
lea Sys_Messages(a5),a0 Enleve config interpreteur
jsr A5_Free
lea PathAct(a5),a0 Enleve pathact
jsr A5_Free
move.l AdrIcon(a5),d0 Enleve l'icone
beq.s .SkipI
move.l d0,a0
move.l IconBase(a5),a6
jsr -90(a6)
.SkipI
move.l $4.w,a6 Ferme icon.library
move.l IconBase(a5),d0
beq.s .Skip1
move.l d0,a1
jsr _LVOCloseLibrary(a6)
.Skip1
move.l FloatBase(a5),d0 Ferme les librairies mathematiques
beq.s .SkipM1
move.l d0,a1
jsr _LVOCloseLibrary(a6)
.SkipM1 bsr Math_Close
bsr Libraries_Free Libere les librairies
move.l Sys_WAd(a5),a0 Enleve AMOS.Library
jsr 16(a0)
move.l DosBase(a5),a6
move.l Sys_WSegment(a5),d1
jsr _LVOUnLoadSeg(a6)
move.l DosBase(a5),a3 Affiche le message d'erreur
move.l T_IntBase(a5),a4
move.l Sys_Message(a5),d7
bsr Panic_Message
move.l $4.w,a6 Ferme graphics.library
move.l T_GfxBase(a5),d0
beq.s .SkipG
move.l d0,a1
jsr _LVOCloseLibrary(a6)
.SkipG
move.l DosBase(a5),a1 dos
jsr _LVOCloseLibrary(a6)
move.l T_IntBase(a5),a1 Intuition
jsr _LVOCloseLibrary(a6)
move.l Sys_Message(a5),d7 Plus de datazone
move.l Sys_AData(a5),a1
move.l Sys_LData(a5),d0
move.l $4.w,a6 Liberation directe!
jsr _LVOFreeMem(a6)
; Sortie d'AMOSPro!
; ~~~~~~~~~~~~~~~~~
Get_Out move.l SaveSp(pc),a7
tst.l d7
beq.s .PaMe
move.l $4.w,a6
jsr _LVOForbid(a6)
move.l d7,a1
jsr -378(a6)
.PaMe moveq #0,d0
rts
; Fermeture des librairies mathematiques
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Math_Close
move.l a6,-(sp)
move.l $4.w,a6
move.l MathBase(a5),d0
beq.s .SkipM2
move.l d0,a1
jsr _LVOCloseLibrary(a6)
clr.l MathBase(a5)
.SkipM2 move.l DFloatBase(a5),d0
beq.s .SkipM3
move.l d0,a1
jsr _LVOCloseLibrary(a6)
clr.l DFloatBase(a5)
.SkipM3 move.l DMathBase(a5),d0
beq.s .SkipM4
move.l d0,a1
jsr _LVOCloseLibrary(a6)
clr.l DMathBase(a5)
.SkipM4 move.l (sp)+,a6
rts
; Imprime le message d'erreur dans l'entree courante
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; A3= DosBase
; A4= IntBase
; D7= Message
Panic_Message
move.l Panic(pc),d6 Un message?
beq.s .Exit
tst.l d7 Sous WB?
bne.s .Wb
; Sous DOS-> Message dans la fenetre courante
move.l a3,a6 Handle courant
jsr -60(a6)
move.l d0,d1
beq.s .Exit
lea -128(sp),sp Buffer de travail
move.l sp,d2
move.l d6,a0
move.l d2,a1
.Copy move.b (a0)+,(a1)+
bne.s .Copy
move.b #10,-1(a1)
clr.b (a1)
move.l a1,d3
sub.l d2,d3
jsr _LVOWrite(a6)
lea 128(sp),sp
.Exit rts
; Sous WB-> ouvre une tchote fenetre
.Wb move.l a4,a6 IntBase
lea H_Click(pc),a0
lea H_AutoBody(pc),a1
move.l d6,12(a1)
lea H_AutoClick(pc),a3
move.l a0,12(a3)
sub.l a2,a2
sub.l a0,a0
moveq #0,d0
moveq #0,d1
move.l #560,d2
moveq #50,d3
jsr -348(a6)
bra.s .Exit
; Definition du petit requester
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
H_AutoBody dc.b 2,0
dc.w 1
dc.w 8,7
dc.l 0
dc.l 0
dc.l 0
H_AutoClick dc.b 0,1
dc.w 1
dc.w 5,4
dc.l 0
dc.l 0
dc.l 0
H_Click dc.b " Cancel ",0
even
; Ne pas changer la position du nom, apres dos.library!
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
even
dc.l UserSecu-DosName
DosName dc.b "dos.library",0
UserReg dc.w 14
dc.b "R"^$73 0
dc.b "E"^$73 1
dc.b "G"^$73 2
dc.b "I"^$73 3
dc.b "S"^$73 4
dc.b "T"^$73 5
dc.b "R"^$73 6
dc.b "A"^$73 7
dc.b "T"^$73 8
dc.b "I"^$73 9
dc.b "O"^$73 10
dc.b "N"^$73 11
dc.b " "^$73 12
dc.b "#"^$73 13
UserName dc.w 14
dc.b "N"^$A5 0
dc.b "o"^$A5 1
dc.b "t"^$A5 2
dc.b " "^$A5 3
dc.b "I"^$A5 4
dc.b "n"^$A5 5
dc.b "s"^$A5 6
dc.b "t"^$A5 7
dc.b "a"^$A5 8
dc.b "l"^$A5 9
dc.b "l"^$A5 10
dc.b "e"^$A5 11
dc.b "d"^$A5 12
dc.b "!"^$A5 13
ds.b 32-14+4
even
; Noms des Librairies
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SaveSp dc.l 0
Panic dc.l 0
; Marqueur de version
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VersionN: dc.b " Version "
Version
dc.b 0,"$VER: "
Version
; Messages d'erreur
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Panic_OOMem dc.b "Not enough free memory",0
Panic_Editor dc.b "Cannot load editor",0
Panic_Install dc.b 'Program not installed, start "Install.AMOS" first',0
; Charge l'editeur
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Edit_Load
lea Edit_Segment(a5),a0
lea Edit_Debug(pc),a1
moveq #6,d0
moveq #L_Ed_Start,d1
bsr Program_Load
.Err rts
; Efface l'editeur
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Edit_Free
lea Edit_Segment(a5),a0
bra Program_Free
; Charge le moniteur
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mon_Load
move.l Cur_Banks(a5),-(sp)
; Le moniteur lui-meme
; ~~~~~~~~~~~~~~~~~~~~
lea Mon_Segment(a5),a0
lea Mon_Debug(pc),a1
moveq #10,d0
moveq #L_Mon_Start,d1
bsr Program_Load
; Charge la banque de resource, si necessaire
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.Skip1 tst.l Mon_Banks(a5)
bne.s .Skip2
lea Mon_Banks(a5),a0
move.l a0,Cur_Banks(a5)
moveq #11,d0 Nom de la banque
bsr Sys_GetMessage
bsr Sys_AddPath + path systeme
move.l #1005,d2
bsr D_Open
beq.s .DErr
moveq #-1,d0
JJsr L_Bnk.Load
bne .Err
bsr D_Close
.Skip2
; Ok, pas d'erreur
; ~~~~~~~~~~~~~~~~
move.l (sp)+,Cur_Banks(a5)
moveq #0,d0
rts
; Erreur: efface tout!
; ~~~~~~~~~~~~~~~~~~~~
.DErr moveq #-2,d0 File not found
.Err move.l (sp)+,Cur_Banks(a5)
move.w d0,-(sp)
bsr Mon_Free
move.w (sp)+,d0
rts
; Efface le moniteur
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mon_Free
move.l Cur_Banks(a5),-(sp)
; Enleve le moniteur
; ~~~~~~~~~~~~~~~~~~
lea Mon_Segment(a5),a0
bsr Program_Free
; Enleve les banques
; ~~~~~~~~~~~~~~~~~~
.Skip1 tst.l Mon_Banks(a5)
beq.s .Skip2
lea Mon_Banks(a5),a0
move.l a0,Cur_Banks(a5)
JJsr L_Bnk.EffAll
.Skip2 move.l (sp)+,Cur_Banks(a5)
rts
; Charge le programme (a0) / Nom #D0 / Branchements D1
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Program_Load
move.l a0,a2 Adresse du segment
move.l d1,d2 Numero de la premiere fonction
IFNE Debug=2
move.l a1,(a2)
ENDC
IFEQ Debug=2
tst.l (a2)
bne.s .Skip
bsr Sys_GetMessage Nom du programme
bsr Sys_AddPath + path systeme
move.l Name1(a5),d1
move.l a6,-(sp)
move.l DosBase(a5),a6
jsr _LVOLoadSeg(a6)
move.l (sp)+,a6
move.l d0,(a2)
beq.s .Err
ENDC
; Loke les adresses des routines dans les branchements
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.Skip move.l (a2),d0
IFEQ Debug=2
lsl.l #2,d0
addq.l #4,d0
ENDC
move.l d0,a0
move.l AdTokens(a5),a1
lsl.w #2,d2
add.w #LB_Size+4,d2
sub.w d2,a1
bra.s .In
.Loop add.l d0,d1
move.l d1,-(a1)
.In move.l (a0)+,d1
bne.s .Loop
; OK, pas d'erreur
; ~~~~~~~~~~~~~~~~
moveq #0,d0
rts
.Err moveq #1,d0
rts
; Efface le programme A0
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Program_Free
IFEQ Debug=2
move.l (a0),d1
beq.s .Skip
clr.l (a0)
move.l a6,-(sp)
move.l DosBase(a5),a6
jsr _LVOUnLoadSeg(a6)
move.l (sp)+,a6
ENDC
.Skip rts
; Effacement du buffer mouse
; ~~~~~~~~~~~~~~~~~~~~~~~~~~
EffMouse
lea PI_AdMouse(a5),a0
jmp A5_Free
; Efface la banque de resource file-selector
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
EffFSel lea Sys_Banks(a5),a0
move.l a0,Cur_Banks(a5)
moveq #16,d0
JJsr L_Bnk.Eff
rts
; AddPath sur un nom+command line, retourne la command line en A0
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sys_AddPathCom
movem.l a1/d1,-(sp)
move.l a0,a1
.Lim1 move.b (a1)+,d1
beq.s .Lim2
cmp.b #" ",d1
bne. .Lim1
.Lim2 move.b -1(a1),d1
clr.b -1(a1)
bsr Sys_AddPath
move.b d1,-1(a1)
bne.s .Lim3
subq.l #1,a1
.Lim3 move.l a1,a0
movem.l (sp)+,a1/d1
rts
; Additionne le pathname du dossier AMOS_System, si pas de path defini!
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sys_AddPath
movem.l a1/a2,-(sp)
move.l Name1(a5),a2
move.l a0,a1
.Ess move.b (a1)+,d0
cmp.b #":",d0
beq.s .Cop2
tst.b d0
bne.s .Ess
lea Sys_Pathname(a5),a1
.Cop1 move.b (a1)+,(a2)+
bne.s .Cop1
subq.l #1,a2
.Cop2 move.b (a0)+,(a2)+
bne.s .Cop2
movem.l (sp)+,a1/a2
rts
; Retourne le message default_resource D0
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Def_GetMessage
move.l Sys_Resource(a5),a0
add.l 6(a0),a0
bra.s GetMessage
; Routine, retourne le message systeme D0
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sys_GetMessage
move.l Sys_Messages(a5),a0
GetMessage
move.w d1,-(sp)
clr.w d1
cmp.l #0,a0
beq.s .Big
addq.l #1,a0
bra.s .In
.Loop move.b (a0),d1
cmp.b #$ff,d1
beq.s .Big
lea 2(a0,d1.w),a0
.In subq.w #1,d0
bgt.s .Loop
.Out move.w (sp)+,d1
move.b (a0)+,d0
rts
.Big lea .Fake(pc),a0
bra.s .Out
.Fake dc.b 0,0,0,0
; Verification de l'installation
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sys_VerInstall
move.w d0,-(sp)
move.w UserName(pc),d0
beq.s .Skip
move.w UserReg(pc),d0
.Skip movem.w (sp)+,d0
rts
; Enleve le codage: D0=XOR
; ~~~~~~~~~~~~~~~~~~~~~~~~
Sys_UnCode
movem.l a0/a1/d1/d2/d3,-(sp)
moveq #0,d2
move.w (a0)+,d1
move.w d1,(a1)+
subq.w #1,d1
bmi.s .Skip
.Loop move.b (a0)+,d3
eor.b d0,d3
add.b d3,d2
move.b d3,(a1)+
dbra d1,.Loop
.Skip move.w d2,d0
movem.l (sp)+,a0/a1/d1/d2/d3
rts
******************************************************************
dc.b $17,$09,$19,$92
UserSecu ds.b 34
******************************************************************
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Clear CPU Caches, quel que soit le systeme
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sys_ClearCache
; - - - - - - - - - - - - -
movem.l a0-a1/a6/d0-d1,-(sp)
move.l $4.w,a6
cmp.w #37,WB2.0(a5) A partir de V37
bcc.s .Skip
jsr FindTask(a6)
bra.s .Exit
.Skip jsr _LVOCacheClearU(a6) CacheClearU
.Exit movem.l (sp)+,a0-a1/a6/d0-d1
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Wait vbl multi tache
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sys_WaitMul
; - - - - - - - - - - - - -
movem.l a0-a1/a6/d0-d1,-(sp)
; Inhibition
SyCall Test_Cyclique
; Attente multitache
move.l T_GfxBase(a5),a6
jsr -270(a6)
movem.l (sp)+,a0-a1/a6/d0-d1
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Force le recalcul des listes copper
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ReCop: SyCall WaitVbl
EcCall CopForce
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; ARRET DES LIBRAIRIES
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Libraries_Stop
; - - - - - - - - - - - - - - - -
movem.l a2-a6/d2-d7,-(sp)
moveq #26-1,d2
lea ExtAdr+26*16-16(a5),a2
.Loop move.l 8(a2),d0
beq.s .Next
move.l d0,a0
movem.l a2/d2,-(sp)
jsr (a0)
movem.l (sp)+,a2/d2
.Next lea -16(a2),a2
dbra d2,.Loop
moveq #0,d0
bra Ll_Out2
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; EFFACEMENT DES LIBRARIES
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Libraries_Free
; - - - - - - - - - - - - - - - -
bsr Libraries_FreeSizes
movem.l a2-a6/d2-d7,-(sp)
moveq #27-1,d2
lea AdTokens(a5),a2
.Loop move.l (a2),d0
beq.s .Next
move.l d0,a0 La library elle meme...
clr.l (a2)
move.l LB_MemAd(a0),a1
move.l LB_MemSize(a0),d0
SyCall MemFree
.Next addq.l #4,a2 Library suivante...
dbra d2,.Loop
moveq #0,d0
bra Ll_Out2
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; LIBERATION DE LA TABLE DES TAILLES
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Libraries_FreeSizes
; - - - - - - - - - - - - - - - -
movem.l d2-d7/a2-a6,-(sp)
lea AdTokens(a5),a2
moveq #27-1,d2
.Loop move.l (a2)+,d0
beq.s .Skip
move.l d0,a0
move.l LB_LibSizes(a0),d0
beq.s .Skip
clr.l LB_LibSizes(a0)
move.l d0,a1
move.l -(a1),d0
addq.l #4,d0
jsr RamFree
.Skip dbra d2,.Loop
moveq #0,d0
Ll_Out2 movem.l (sp)+,d2-d7/a2-a6
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; RESERVATION / LIBERATION MEMOIRE (ancienne!)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Mise a zero!
; ~~~~~~~~~~~~~~~~~~
RamFast move.l a0,-(sp)
SyCall MemFastClear
move.l a0,d0
move.l (sp)+,a0
rts
RamChip move.l a0,-(sp)
SyCall MemChipClear
move.l a0,d0
move.l (sp)+,a0
rts
; NON mise a zero!
; ~~~~~~~~~~~~~~~~~~~~~~
RamFast2
move.l a0,-(sp)
SyCall MemFast
move.l a0,d0
move.l (sp)+,a0
rts
RamChip2
move.l a0,-(sp)
SyCall MemChip
move.l a0,d0
move.l (sp)+,a0
rts
; Liberation
; ~~~~~~~~~~~~~~~~
RamFree move.l a0,-(sp)
SyCall MemFree
move.l (sp)+,a0
rts
; Reserve / Libere le buffer temporaire
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ResTempBuffer
movem.l d1/a1,-(sp)
move.l d0,d1
; Libere l'ancien buffer
move.l TempBuffer(a5),d0
beq.s .NoLib
move.l d0,a1
move.l -(a1),d0
addq.l #4,d0
bsr.s RamFree
clr.l TempBuffer(a5)
; Reserve le nouveau
.NoLib move.l d1,d0
beq.s .Exit
addq.l #4,d0
bsr RamFast
beq.s .Exit
move.l d0,a0
move.l d1,(a0)+
move.l a0,TempBuffer(a5)
move.l d1,d0
; Branche les routines de liberation automatique
movem.l a0-a2/d0-d1,-(sp)
lea .LibClr(pc),a1
lea Sys_ClearRoutines(a5),a2
SyCall AddRoutine
lea .LibErr(pc),a1
lea Sys_ErrorRoutines(a5),a2
SyCall AddRoutine
movem.l (sp)+,a0-a2/d0-d1
.Exit movem.l (sp)+,d1/a1
rts
; Structures liberation
; ~~~~~~~~~~~~~~~~~~~~~
.LibClr dc.l 0
moveq #0,d0
bra.s ResTempBuffer
.LibErr dc.l 0
moveq #0,d0
bra.s ResTempBuffer
; Reserve un espace mémoire sur (a5)
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; A0= Adresse dans (a5)
; D0= Longueur
; D1= Flags
A5_Reserve
move.l a1,-(sp)
move.l a0,a1
addq.l #4,d0
SyCall MemReserve
beq.s .Out
subq.l #4,d0
move.l d0,(a0)+
move.l a0,(a1)
.Out move.l (sp)+,a1
rts
; Efface un espace mémoire sur (a5)
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; A0= Adresse dans (a5)
A5_Free
movem.l a0/a1/d0,-(sp)
move.l (a0),d0
beq.s .Skip
clr.l (a0)
move.l d0,a1
move.l -(a1),d0
addq.l #4,d0
SyCall MemFree
.Skip movem.l (sp)+,a0/a1/d0
rts
;
; NOUVELLE ROUTINES DISQUE
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
; OPEN: ouvre le fichier systeme (diskname1) access mode D2
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D_Open move.l Name1(a5),d1
D_OpenD1
move.l a6,-(sp)
move.l DosBase(a5),a6
jsr _LVOOpen(a6)
move.l (sp)+,a6
move.l d0,Handle(a5)
rts
; READ fichier systeme D3 octets dans D2
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D_Read movem.l d1/a0/a1/a6,-(sp)
move.l Handle(a5),d1
move.l DosBase(a5),a6
jsr _LVORead(a6)
movem.l (sp)+,d1/a0/a1/a6
cmp.l d0,d3
rts
; WRITE fichier systeme D3 octets de D2
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D_Write
movem.l d1/a0/a1/a6,-(sp)
move.l Handle(a5),d1
move.l DosBase(a5),a6
jsr _LVOWrite(a6)
movem.l (sp)+,d1/a0/a1/a6
cmp.l d0,d3
rts
; SEEK fichier system D3 mode D2 deplacement
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D_Seek move.l Handle(a5),d1
move.l a6,-(sp)
move.l DosBase(a5),a6
jsr _LVOSeek(a6)
move.l (sp)+,a6
tst.l d0
rts
; CLOSE fichier systeme
; ~~~~~~~~~~~~~~~~~~~~~
D_Close
movem.l d0/d1/a0/a1/a6,-(sp)
move.l Handle(a5),d1
beq.s .Skip
clr.l Handle(a5)
move.l DosBase(a5),a6
jsr _LVOClose(a6)
.Skip movem.l (sp)+,d0/d1/a0/a1/a6
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; MONITOR
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InMonitor
; - - - - - - - - - - - - -
bsr Prg_FirstRun Autorise?
tst.l Edit_Segment(a5)
beq.s .ErrE
Ijsr L_Ed_CloseEditor
Ijsr L_Prg_ReSetBanks Remet les banques
bsr Mon_Load Charge le moniteur
bne.s .Err
Ijsr L_Mon_In_Program
bne.s .Mem
Ret_Inst
.ErrE moveq #13,d0
Ijmp L_Error
.Err cmp.w #-1,d0
beq.s .Mem
Ijmp L_DiskError
.Mem Ijmp L_OOfMem
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; KILL EDITOR
; KILL EDITOR: ne fonctionne que le pour le premier programme!
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InKillEditor
; - - - - - - - - - - - - -
bsr Prg_FirstRun Autorise?
tst.l Edit_Segment(a5) Deja ferme?
beq.s KEExit
; Fait un close editor d'abord
tst.b PI_CloseEd(a5) Autorise?
beq.s CloCloX
Ijsr L_Ed_CloseEditor
; Peut-on faire le KILL editor?
tst.b PI_KillEd(a5) Autorise?
beq.s CloCloX
tst.l Mon_Base(a5) Pas si moniteur en route!
bne.s CloCloX
Ijsr L_Ed_KillEditor
bsr Edit_Free Enleve de la memoire
bsr Mon_Free Tant qu'à faire...
lea RunErr_NoEditor(pc),a0
move.l a0,Prg_JError(a5) Branchement en fin de programme
clr.w T_AMOState(a5) Mode RUN-ONLY
; Sortie commune
CloCloX lea Equ_Base(a5),a0 Libere les equates
bsr A5_Free
Ijsr L_Prg_ReSetBanks Remet les banques
move.w ScOn(a5),d1
beq.s KEExit
subq.w #1,d1
EcCall Active
KEExit Ret_Inst
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; CLOSE EDITOR
; ne fonctionne que pour le premier programme!
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InCloseEditor
; - - - - - - - - - - - - -
bsr Prg_FirstRun
tst.b PI_CloseEd(a5) Autorise?
beq.s KEExit
tst.l Edit_Segment(a5) Deja ferme?
beq.s KEExit
Ijsr L_Ed_CloseEditor
bra.s CloCloX
; Peut-on fermer l'editeur ?
; ~~~~~~~~~~~~~~~~~~~~~~~~~~
Prg_FirstRun
tst.w Direct(a5)
bne.s .Err
tst.b Prg_Accessory(a5)
bne.s .Non
move.l Prg_Runned(a5),a0 Un programme en dessous?
tst.l Prg_Previous(a0)
bne.s .Non
rts
.Non addq.l #4,sp
Ret_Inst
.Err moveq #17,d0 Illegal direct mode
Ijmp L_Error
; __________________________________________________________________________
;
; Erreurs RUN-ONLY
; __________________________________________________________________________
;
RunErr_RunOnly
move.w #-1,-(sp)
bra.s RunErr_Reload
; __________________________________________________________________________
;
; Erreurs editeur ferme...
; __________________________________________________________________________
;
RunErr_NoEditor
clr.w -(sp)
RunErr_Reload
movem.l a0-a1/d0-d1,-(sp)
move.l Cur_Banks(a5),-(sp) Donnees courantes...
move.l Cur_Dialogs(a5),-(sp)
cmp.w #1002,d0 System?
beq TheEnd
bsr Sys_VerInstall Si pas installe!
beq TheEnd
bsr Reset_Request Requester back to AMOS
bsr Edit_Load Charge l'editeur
bne .Again
JJsr L_Ed_Cold
beq.s .Ok
cmp.b #1,d0 Out of memory?
bne TheEnd_Editor Fichiers introuvables : tant pis!
; Efface au maximum la memoire
.Again move.l (sp),Cur_Dialogs(a5) Banques du programme
move.l 4(sp),Cur_Banks(a5)
bsr MemMaximum Grab as much memory as possible
bsr Edit_Load Charge eventuellement
bne.s .AAgain
JJsr L_Ed_Cold
beq.s .Ok
; Efface les banques du programme!