-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path+CompExt.s
1582 lines (1493 loc) · 33 KB
/
+CompExt.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.2200002....220002...22.....200002..0000000000002...................
; ...220000..222000002...20000..........200000......2222........................
; ...000000000000000000..200000..........00002..................................
; ..220000000022020000002.200002.........22.......______________________________
; ..0000002........2000000220022.................|
; .200000............2002........................| AMOS Compiler Extension
; .200002........................................| For AMOSPro 2.0 and over
; 220002.........................................|______________________________
; ______________________________________________________________________________
;
;---------------------------------------------------------------------
; Include the files automatically calculated by
; Library_Digest.AMOS
;---------------------------------------------------------------------
Include "+AMOS_Includes.s"
Include "+Version.s"
Include "+Compext_Size.s"
Include "+Compext_Labels.s"
INCDIR "includes/"
Include "pp/powerpacker_lib.i"
Include "pp/ppbase.i"
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Initialisation stuff
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExtNb equ 5-1
Dlea MACRO
move.l ExtAdr+ExtNb*16(a5),\2
add.w #\1-DT,\2
ENDM
Dload MACRO
move.l ExtAdr+ExtNb*16(a5),\1
ENDM
Cmp_Magic equ "Gaga"
dc.l C_Tk-C_Off
dc.l C_Lib-C_Tk
dc.l C_Title-C_Lib
dc.l C_End-C_Title
dc.w 0
dc.b "AP20"
;---------------------------------------------------------------------
; Creates the pointers to functions
;---------------------------------------------------------------------
MCInit
C_Off
REPT Lib_Size
MC
ENDR
;---------------------------------------------------------------------
; TOKEN TABLE
;---------------------------------------------------------------------
; TOKEN_START
C_Tk
dc.w L_Nul,L_Nul
dc.b $80,-1
TkCmp dc.w L_CmpCall,L_Nul
dc.b "cmpcal","l"+$80,"I",-1
TkCOp dc.w L_CmpOpt,L_Nul
dc.b "comp option","s"+$80,"I2",-1
TkTston dc.w L_Rien,L_Nul
dc.b "comp test o","n"+$80,"I",-1
TkTstof dc.w L_Rien,L_Nul
dc.b "comp test of","f"+$80,"I",-1
TkTst dc.w L_Rien,L_Nul
dc.b "comp tes","t"+$80,"I",-1
dc.w L_Compile1,L_Nul
dc.b "!compil","e"+$80,"I2",-2
dc.w L_Compile2,L_Nul
dc.b $80,"I2,0",-1
dc.w L_Nul,L_CompErr
dc.b "comp err","$"+$80,"2",-1
dc.w L_CompLoad0,L_Nul
dc.b "!comp loa","d"+$80,"I",-2
dc.w L_CompLoad1,L_Nul
dc.b $80,"I2",-1
dc.w L_CompDel,L_Nul
dc.b "comp de","l"+$80,"I",-1
dc.w L_Nul,L_CompHere
dc.b "comp her","e"+$80,"0",-1
dc.w L_Nul,L_CompSize
dc.b "comp siz","e"+$80,"0",-1
dc.w L_Nul,L_Squash
dc.b "squas","h"+$80,"00,0,0,0,0",-1
dc.w L_Nul,L_UnSquash
dc.b "unsquas","h"+$80,"00,0",-1
dc.w L_InppSave2,L_Nul
dc.b "!ppsav","e"+$80,"I2,0",-2
dc.w L_InppSave3,L_Nul
dc.b $80,"I2,0,0",-1
dc.w L_InppLoad1,L_Nul
dc.b "!pploa","d"+$80,"I2",-2
dc.w L_InppLoad2,L_Nul
dc.b $80,"I2,0",-1
; TOKEN_END
dc.w 0
dc.l 0
;---------------------------------------------------------------------
Lib_Ini 0
;---------------------------------------------------------------------
C_Lib
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; COLD START
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Def Cmp_Cold
; - - - - - - - - - - - - -
cmp.l #"APex",d1 V1.10 or over?
bne.s .BadVer
* Poke les adresses
lea CD(pc),a0
move.l a0,ExtAdr+ExtNb*16(a5)
lea CmpEnd(pc),a0
move.l a0,ExtAdr+ExtNb*16+8(a5)
* Terminé!
.NoCom moveq #ExtNb,d0 Numero extension
move.w #VerNumber,d1 Current AMOSPro Version
rts
* Bad version
.BadVer sub.l a0,a0
moveq #-1,d0 Retour a l'envoyeur!
rts
******* Routine END
CmpEnd: Rbra L_CompDel
; ---------------------------------------------------------------------
; DATA ZONE
CD
Cmp_Vect dc.l 0
Cmp_Jump dc.l 0
Cmp_NSteps dc.l 0
Cmp_Config dc.l 0
pp_Base dc.l 0
pp_Color dc.l 0
pp_Flash dc.l 0
pp_CrunchInfo dc.l 0
Cmp_Name1 dc.b "C:"
Cmp_Name2 dc.b "APCmp",0
CSize dc.l 0
CNumb dc.l 0
LErreur dc.w 0
Erreur ds.b 80
pp_Name dc.b "powerpacker.library",0
even
; ---------------------------------------------------------------------
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; COMPCALL: appel du programme compile!
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par CmpCall
; - - - - - - - - - - - - -
moveq #0,d0
Rbra L_Custom
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; COMP OPTIONS "command line"
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par CmpOpt
; - - - - - - - - - - - - -
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; COMPILE "command string"
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par Compile1
; - - - - - - - - - - - - -
move.l d3,-(a3)
Dload a2
Rbsr L_CompLoad0
move.l (a3)+,a0
moveq #0,d0
move.w (a0)+,d0
move.l Cmp_Jump-CD(a2),a1
jsr 4(a1)
Rbra L_FinComp
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; COMPILE "Command line",magic
; Special COMPILER.AMOS
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par Compile2
; - - - - - - - - - - - - -
Dload a2
move.l (a3)+,a0
moveq #0,d0
move.w (a0)+,d0
cmp.w #4,d0
bne.s .Start
cmp.l #"Step",(a0)
beq.s .Step
cmp.l #"Conf",(a0)
beq.s .Conf
cmp.l #"Cont",(a0)
beq.s .Cont
cmp.l #"Stop",(a0)
beq.s .Stop
Rbra L_FCall
; Stocke le nombre de pas
; ~~~~~~~~~~~~~~~~~~~~~~~
.Step move.l d3,Cmp_NSteps-CD(a2)
rts
; Stocke l'adresse de la config
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.Conf move.l d3,Cmp_Config-CD(a2)
rts
; Premier appel du compilateur
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.Start cmp.l #Cmp_Magic,d3 Veut un magic!
Rbne L_FCall
move.l Cmp_NSteps-CD(a2),d1
move.l Cmp_Config-CD(a2),d2
tst.l Cmp_Vect-CD(a2)
Rbeq L_FCall
move.l Cmp_Jump-CD(a2),a1
jsr 8(a1)
bra.s .Fin
; Arret du compilateur
; ~~~~~~~~~~~~~~~~~~~~
.Stop cmp.l #Cmp_Magic,d3
Rbne L_FCall
move.l Cmp_Jump-CD(a2),a1
jsr 16(a1)
bra.s .Fin
; Appels suivants
; ~~~~~~~~~~~~~~~
.Cont cmp.l #Cmp_Magic,d3
Rbne L_FCall
move.l Cmp_Jump-CD(a2),a1
jsr 12(a1)
; Retour de APCmp
; ~~~~~~~~~~~~~~~
.Fin clr.l ParamE(a5) Zero si termine!
tst.l d0 D0>0 : message normal
Rbpl L_FinComp
cmp.w #-1,d0
Rbne L_OOMem Out of memory!
move.l d1,ParamE(a5) Position dans PARAM
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; =COMP ERR$
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par CompErr
; - - - - - - - - - - - - -
Dload a2
moveq #0,d3
move.w LErreur-CD(a2),d3
beq.s .Vide
Rjsr L_Demande
move.w d3,d0
move.l a0,d3
move.w d0,(a1)+
subq.w #1,d0
lea Erreur-CD(a2),a0
.Loop1 move.b (a0)+,(a1)+
dbra d0,.Loop1
move.w a1,d1
and.w #$0001,d1
add.w d1,a1
move.l a1,HiChaine(a5)
moveq #2,d2
rts
.Vide move.l ChVide(a5),d3
moveq #2,d2
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; COMP TEST ON/OFF-> RIEN!
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par Rien
; - - - - - - - - - - - - -
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; COMP LOAD
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par CompLoad0
; - - - - - - - - - - - - -
Dload a2
lea Cmp_Name2-CD(a2),a0 APCMP
Rjsr L_Sys_AddPath + path systeme
Rbra L_CLoad = nom complet!
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; COMP LOAD "nom"
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par CompLoad1
; - - - - - - - - - - - - -
move.l d3,a2
Rjsr L_NomDisc Compute le nom >>> name1
Rbra L_CLoad
; Charge le compilateur, nom= NAME1
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lib_Def CLoad
movem.l a0-a2/d0-d2,-(sp)
Dload a2
tst.l Cmp_Vect-CD(a2)
bne.s .Loaded
move.l Name1(a5),d1
move.l a6,-(sp)
move.l DosBase(a5),a6
jsr -150(a6)
move.l (sp)+,a6
move.l d0,Cmp_Vect-CD(a2)
Rbeq L_NFound
lsl.l #2,d0
addq.l #4,d0
move.l d0,a0
cmp.l #"APcp",20(a0)
bne.s .Error
move.l a0,Cmp_Jump-CD(a2)
.Loaded movem.l (sp)+,a0-a2/d0-d2
rts
.Error Rbsr L_CompDel
moveq #95,d0
Rjmp L_Error
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; EFFACE LE COMPILATEUR
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Def CompDel
; - - - - - - - - - - - - -
movem.l a0-a2/d0-d2,-(sp)
Dload a2
move.l Cmp_Vect-CD(a2),d1
beq.s .skip
clr.l Cmp_Vect-CD(a2)
clr.l Cmp_Jump-CD(a2)
move.l a6,-(sp)
move.l DosBase(a5),a6
jsr -156(a6)
move.l (sp)+,a6
.skip movem.l (sp)+,a0-a2/d0-d2
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; ERROR MESSAGES
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Def FCall
; - - - - - - - - - - - - -
moveq #23,d0
Rjmp L_Error
Lib_Def NFound
moveq #81,d0
Rjmp L_Error
Lib_Def OOMem
moveq #24,d0
Rjmp L_Error
Lib_Def Errdisc
Rjmp L_DiskError
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; =COMPHERE
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par CompHere
; - - - - - - - - - - - - -
Dload a0
moveq #0,d3
tst.l Cmp_Vect-CD(a0)
beq.s .skip
moveq #-1,d3
.skip Ret_Int
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Fin de compilation
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Def FinComp
; - - - - - - - - - - - - -
Dload a2
move.l d1,CSize-CD(a2)
move.l d2,CNumb-CD(a2)
clr.w LErreur-CD(a2)
tst.l d0
beq.s Cmp3
moveq #0,d2
lea Erreur-CD(a2),a1
Cmp2 cmp.w #80,d2
bcc.s .Long
addq.w #1,d2
move.b (a0)+,(a1)+
bne.s Cmp2
.Long subq.w #1,d2
move.w d2,LErreur-CD(a2)
Cmp3 rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; =COMP SIZE
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par CompSize
; - - - - - - - - - - - - -
Dload a0
move.l CSize-CD(a0),d3
move.l CNumb-CD(a0),CSize-CD(a0)
clr.l CNumb-CD(a0)
Ret_Int
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; PPLOAD "bank"
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par InppLoad1
; - - - - - - - - - - - - -
move.l d3,-(a3)
move.l #EntNul,d3
Rbra L_ppLoad
; - - - - - - - - - - - - -
Lib_Par InppLoad2
; - - - - - - - - - - - - -
cmp.l #$10000,d3
Rbge L_FCall
Rbra L_ppLoad
; - - - - - - - - - - - - -
Lib_Def ppLoad
; - - - - - - - - - - - - -
; illegal
move.l (a3)+,a2
Rjsr L_NomDisc
; Rbsr L_Openpplib
; move.l d0,a6
; lea -8(sp),sp
; move.l Name1(a5),a0
; moveq #0,d0
; move.l #Public|Chip,d1
; lea (sp),a1
; lea 4(sp),a2
; move.l #-1,a3
; jsr _LVOppLoadData(a6)
; illegal
move.l #1005,d2
Rjsr L_D_Open
Rbeq L_Errdisc
move.l d3,d0
Rbsr L_ppBnk_Load
Rjsr L_D_Close
Rjsr L_Bnk.Change
rts
; - - - - - - - - - - - - -
Lib_Def ppBnk_Load
; - - - - - - - - - - - - -
movem.l d2-d5/a2-a3,-(sp)
Rjsr L_SaveRegs
move.l d0,d5
moveq #0,d0
Rjsr L_ResTempBuffer
; Lis l'entete
move.l Buffer(a5),d2
moveq #4,d3
Rjsr L_D_Read
Rbne L_Errdisc
move.l d2,a2
cmp.l #"PPbk",(a2)
bne .Errbadformat
moveq #12,d3
Rjsr L_D_Read
Rbne L_Errdisc
move.w 2(a2),d2
btst #Bnk_BitBob,d2
bne.s .BbIc
btst #Bnk_BitIcon,d2
bne.s .BbIc
; Une banque normale
move.l 4(a2),d0 Longueur banque
add.l #8+8,d0 + Flags + Header.lst
move.l #Public,d1
btst #Bnk_BitChip,d2
beq.s .Skip
move.l #Public|Chip,d1
.Skip SyCall MemReserve Reserve le tempbuffer
Rbeq L_OOMem
subq.l #4,d0
move.l d0,(a0)+
move.l a0,TempBuffer(a5)
addq.l #4,a0 Pointe au niveau des flags
move.l a0,d2
move.l 8(a2),d3 Longueur de la partie PP
Rbsr L_LoadUncrunch
; Efface la banque origine
tst.l d5
bpl.s .Skip3
moveq #0,d5
move.w (a2),d5
.Skip3 move.l d5,d0
Rjsr L_Bnk.Eff
; Branche la banque dans la liste
move.l Cur_Banks(a5),a0
move.l TempBuffer(a5),a1
clr.l TempBuffer(a5)
move.l -(a1),d0
subq.l #4,d0
move.l d0,4(a1) Met la longueur en 2
move.l (a0),(a1) Branche dans la liste
move.l a1,(a0)
addq.l #8,a1
clr.w (a1)+
move.w d5,(a1)+ Numero de la banque
addq.l #2,a2
move.w (a2)+,(a1)+ Flags
clr.w (a1)+
bra .Out
; Une banque de sprites / icons
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.BbIc move.l 4(a2),d0 Longueur tempbuffer
addq.l #8,d0 + Securite pp
Rjsr L_ResTempBuffer
Rbeq L_OOMem
move.l a0,d2 Adresse
move.l 8(a2),d3 Longueur
Rbsr L_LoadUncrunch Charge + Decompacte
move.l TempBuffer(a5),a3
addq.l #8,a3
; Sprite / Icons / Load / Append
move.w 2(a2),d0
btst #Bnk_BitBob,d0
beq.s .Icons
; Bobs / Sprites
move.w (a3)+,d6 Nombre de bobs
tst.l d5 Overwrite?
ble.s .Over
Rjsr L_Bnk.GetBobs Demande le nombre de bobs
beq.s .Over 0= overwrite
moveq #1,d0 Append!
move.w d6,d1
move.w (a0),d5 Nombre actuel
add.w d5,d1
bra.s .Res
.Over moveq #0,d0
move.w d6,d1
clr.w d5
.Res Rjsr L_Bnk.ResBob Va reserve la place...
Rbne L_OOMem
bra.s .BB
; Icons
.Icons move.w (a3)+,d6 Nombre d'icons
tst.l d5 Overwrite?
ble.s .IOver
Rjsr L_Bnk.GetIcons Demande le nombre de bobs
beq.s .IOver 0= overwrite
moveq #1,d0 Append!
move.w d6,d1
move.w (a0),d5 Nombre actuel
add.w d5,d1
bra.s .IRes
.IOver moveq #0,d0
move.w d6,d1
clr.w d5
.IRes Rjsr L_Bnk.ResIco Va reserve la place...
Rbne L_OOMem
; Partie commune
; ~~~~~~~~~~~~~~
.BB lsl.w #3,d5 Pointe le debut des nouveaux
lea 2(a0,d5.w),a2
subq.w #1,d6 D6= compteur
bmi.s .Pal
.LSLoop clr.l (a2)+ Raz
clr.l (a2)+
move.w (a3)+,d0 Prend les caracteristiques
mulu (a3)+,d0
mulu (a3)+,d0
addq.l #4,a3
lsl.l #1,d0 Vide?
beq.s .Rien
move.l d0,d3 Reserve la memoire
add.l #10,d0
SyCall MemChip
Rbeq L_OOMem
move.l a0,-8(a2) Poke le pointeur
move.l -10(a3),(a0)+ TX/TY
move.w -6(a3),(a0)+
move.w -4(a3),(a0) Plus de FLAGS!
and.w #$3FFF,(a0)+
move.w -2(a3),(a0)+
move.l a0,a1 Copie l'image
move.l a3,a0
move.l d3,d0
Rjsr L_TransMem
move.l a0,a3
.Rien dbra d6,.LSLoop
; Recopie la palette
.Pal moveq #31,d0
.PCopy move.w (a3)+,(a2)+
dbra d0,.PCopy
; Efface le tempbuffer
moveq #0,d0
Rjsr L_ResTempBuffer
; Fini!
.Out Rjsr L_LoadRegs
movem.l (sp)+,a2-a3/d2-d5
rts
.Errbadformat
moveq #2,d0
Rbra L_Custom
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Load + Uncrunch file
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Def LoadUncrunch
; - - - - - - - - - - - - -
movem.l d2-d3/a2,-(sp)
; Ouvre la librairie
Rbsr L_Openpplib
; Charge le header >>> Buffer+16
movem.l d2/d3,-(sp)
move.l Buffer(a5),a2
lea 16(a2),a2
move.l a2,d2
moveq #8,d3
Rjsr L_D_Read
Rbne L_Errdisc
cmp.l #"PP20",(a2)+ A2 pointe sur efficiency
Rbne L_Errdisc
; Charge le fichier
movem.l (sp)+,d2/d3
Rjsr L_D_Read
Rbne L_Errdisc
; Decompacte le fichier
move.l a6,-(sp)
Dload a0
move.l pp_Base-CD(a0),a6
move.l d2,a0
lea 8(a0),a1
add.l d3,a0
moveq #0,d0
jsr _LVOppDecrunchBuffer(a6)
move.l (sp)+,a6
; Fini
movem.l (sp)+,d2-d3/a2
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; PPSAVE "bank",number,efficiency
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par InppSave2
; - - - - - - - - - - - - -
move.l d3,-(a3)
moveq #2,d3
Rbra L_InppSave3
; - - - - - - - - - - - - -
Lib_Par InppSave3
; - - - - - - - - - - - - -
cmp.l #5,d3 Efficiency
Rbcc L_FCall
move.l d3,d5
; Ouvre la librairie
Rbsr L_Openpplib
; Trouve les adresses de la banque
move.l (a3)+,d0
Rjsr L_Bnk.GetAdr
beq .Errnotres
move.l a1,a0
move.l a1,-(sp) Adresse banque origine
bsr B_Length Trouve la longueur totale
; Fabrique le header
move.l Buffer(a5),a2
move.l #"PPbk",(a2)+ Reconnaissance
move.w -8-6(a0),(a2)+ Le numero
move.w -8-4(a0),(a2)+ Flags
move.l d0,(a2)+ Longueur banque / buffer de crunch
; Recopie la banque dans un buffer
Rjsr L_ResTempBuffer
Rbeq L_OOMem
move.l a0,a1
move.l (sp),a0
bsr B_Copie2Buffer
; Va cruncher
move.l TempBuffer(a5),a0
move.l -4(a0),d0
move.l d3,d1
Rbsr L_Crunche
move.l d0,d4
move.l d0,(a2)+ Longueur du buffer crunche
; Ouvre le fichier / Mode NEW
move.l (a3)+,a2
Rjsr L_NomDisc
move.l #1006,d2
Rjsr L_D_Open
beq.s .Errdisc
; Sauve le header
move.l Buffer(a5),d2
moveq #16,d3
Rjsr L_D_Write
bne.s .Errdisc
; Sauve le header pp
Dload a2
move.l Handle(a5),d0
move.l d5,d1
moveq #0,d2
moveq #0,d3
move.l a6,-(sp)
move.l pp_Base-CD(a2),a6
jsr _LVOppWriteDataHeader(a6)
move.l (sp)+,a6
tst.l d0
beq.s .Errdisc
Rbsr L_FreeCrunchInfo
; Sauve la banque pp
move.l TempBuffer(a5),a0
move.l a0,d2
move.l d4,d3
Rjsr L_D_Write
Rbne L_Errdisc
; Ferme le fichier
Rjsr L_D_Close
; Libere les buffer
Rbsr L_FreeCrunchInfo
moveq #0,d0
Rjsr L_ResTempBuffer
addq.l #4,sp
rts
.Errdisc
Rbsr L_FreeCrunchInfo
Rjmp L_DiskError
.Errnotres
Rjmp L_BkNoRes
; Trouve la taille d'une banque de memoire quelconque, avec le nom
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
B_Length
movem.l a0-a1/d1-d2,-(sp)
move.w -8*2+4(a0),d0
btst #Bnk_BitBob,d0
bne.s .BB
btst #Bnk_BitIcon,d0
bne.s .BB
move.l -8*3+4(a0),d0
subq.l #8,d0 Moins les flags
bra.s .Out
; Une banque de bobs / icones
.BB moveq #2+32*2,d0 Pas le nom
move.w (a0)+,d1
subq.w #1,d1
bmi.s .Out
.BBLoop move.l (a0),d2
beq.s .BBNext
move.l d2,a1
move.w (a1)+,d2 SX
mulu (a1)+,d2 SY
mulu (a1)+,d2 NPlan
lsl.l #1,d2 En mots
add.l d2,d0
.BBNext add.l #10,d0 Le header
addq.l #8,a0
dbra d1,.BBLoop
.Out movem.l (sp)+,a0-a1/d1-d2
rts
; Recopie une banque memoire quelconque dans un buffer
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
B_Copie2Buffer
movem.l a0-a2/d0-d3,-(sp)
move.w -8*2+4(a0),d0
btst #Bnk_BitBob,d0
bne.s .BB
btst #Bnk_BitIcon,d0
bne.s .BB
move.l -8*3+4(a0),d0
subq.l #8,d0
subq.l #8,a0
Rjsr L_TransMem
bra.s .Out
; Une banque de bobs / icones
.BB move.w (a0)+,d3 Nombre de bobs
move.w d3,(a1)+
subq.w #1,d3
bmi.s .Out
.BBLoop move.l (a0),d1
beq.s .BBVide
move.l d1,a2
move.l (a2)+,(a1) SX/SY
move.l (a2)+,4(a1) NPLAN/HX
move.w (a2)+,8(a1) HY
move.w (a1)+,d0 SX
mulu (a1)+,d0 SY
mulu (a1)+,d0 NPlan
lsl.l #1,d0 En mots
addq.l #4,a1
exg a0,a2
Rjsr L_TransMem Va copier
exg a0,a2
bra.s .BBNext
.BBVide clr.l (a1)+
clr.l (a1)+
clr.w (a1)+
.BBNext addq.l #8,a0
dbra d3,.BBLoop
; La palette
moveq #31,d0
.BBPal move.w (a0)+,(a1)+
dbra d0,.BBPal
; Fini
.Out movem.l (sp)+,a0-a2/d0-d3
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Crunche le buffer A0 / Longueur D0 / Efficiency D1
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Def Crunche
; - - - - - - - - - - - - -
movem.l a2/d2,-(sp)
Dload a2
movem.l a0/d0/d1,-(sp)
; Quelle rapidite?
moveq #2,d1
move.l #256*1024,d0
SyCall MemFast
bne.s .Ok
moveq #1,d1
move.l #64*1024,d0
SyCall MemFast
bne.s .Ok
moveq #0,d1
bra.s .OMem
.Ok move.l a0,a1
SyCall MemFree
.OMem
; Reserve le Crunch info
move.l 4(sp),d0 Efficiency
move.l a5,a1 User data
lea .Control(pc),a0 Control-C
move.l a6,-(sp)
move.l pp_Base-CD(a2),a6
jsr _LVOppAllocCrunchInfo(a6)
move.l (sp)+,a6
move.l d0,pp_CrunchInfo-CD(a2)
Rbeq L_OOMem
; Crunche le buffer
move.l d0,a0 CrunchInfo
movem.l (sp)+,a1/d0-d1
move.l a6,-(sp)
move.l pp_Base-CD(a2),a6
jsr _LVOppCrunchBuffer(a6)
move.l (sp)+,a6
tst.l d0
beq.s .Erraborted
bmi.s .Errnopack
; Retourne la longueur en D0
movem.l (sp)+,a2/d2
rts
.Erraborted
moveq #9,d0
Rjmp L_Error
.Errnopack
moveq #3,d0
Rbra L_Custom
; Routine de test du control-c
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.Control
movem.l a0-a1/d1/a5,-(sp)
move.l 4+4*4+3*4(sp),a5
move.w T_Actualise(a5),d0
bclr #BitControl,d0
beq.s .Cont
.Stop moveq #0,d0
bra.s .Out
.Cont moveq #1,d0
.Out movem.l (sp)+,a0-a1/d1/a5
rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Libere le crunchinfo
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Def FreeCrunchInfo
; - - - - - - - - - - - - -
Dload a0
move.l pp_CrunchInfo-CD(a0),d0
beq.s .Skip
move.l a6,-(sp)
clr.l pp_CrunchInfo-CD(a0)
move.l pp_Base-CD(a0),a6
move.l d0,a0
jsr _LVOppFreeCrunchInfo(a6)
move.l (sp)+,a6
.Skip rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Ouvre la librairie pp
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Def Openpplib
; - - - - - - - - - - - - -
movem.l a2/a6,-(sp)
Dload a2
move.l pp_Base-CD(a2),d0
bne.s .Open
lea pp_Name-CD(a2),a1
moveq #35,d0
move.l $4.w,a6
jsr _LVOOpenLibrary(a6)
move.l d0,pp_Base-CD(a2)
.Open movem.l (sp)+,a2/a6
tst.l d0
beq.s .Err
rts
.Err moveq #1,d0
Rbra L_Custom
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Ferme la librairie pp
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Def Closepplib
; - - - - - - - - - - - - -
Rbsr L_FreeCrunchInfo
Dload a0
move.l pp_Base-CD(a0),d0
beq.s .Skip
clr.l pp_Base-CD(a0)
move.l d0,a1
move.l a6,-(sp)
move.l $4.w,a6
jsr _LVOCloseLibrary(a6)
move.l (sp)+,a6
.Skip rts
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; = SQUASH(address,length,fast,speed,colour)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par Squash
; - - - - - - - - - - - - -
Rjsr L_SaveRegs
move.l d3,d6
cmp.l #32,d6
Rbcc L_FCall
move.l (a3)+,d7
cmp.l #256,d7
Rbcs L_FCall
cmp.l #4096,d7
Rbcc L_FCall
move.l (a3)+,d5
move.l (a3)+,d1
Rbls L_FCall
move.l (a3)+,d3
moveq #0,d0
lea T_Actualise(a5),a0
movem.l a3-a6/d6/d7,-(sp)
Rbsr L_Sq
movem.l (sp)+,a3-a6/d6/d7
Rjsr L_LoadRegs
Ret_Int
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; = UNSQUASH(address,lenght)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par UnSquash
; - - - - - - - - - - - - -
move.l d3,d1
Rbls L_FCall
move.l (a3)+,d3
moveq #1,d0
movem.l a3-a6/d6/d7,-(sp)
Rbsr L_Sq
movem.l (sp)+,a3-a6/d6/d7
Ret_Int
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; SQUASHER
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Def Sq
Rdata
*
* Squasher II.
*
* Enhanced for varied speed (at a cost of very little inefficiency),
* error checking and pre scan of memory for fast and efficient squashing!
* Routine checks if enough memory is present for pre scan.You can
* turn off pre scan if you want to test it in non scan but you have
* enough memory for scan by setting d5 to -1.
* This is totally compatible with the original ST Squasher.
*
*
* Main Entry d0=0 for squash or d0<>0 for unsquash
* (Check routines below for entry parameters)!
*