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
|
{
This file is part of the Free Pascal run time library.
A file in Amiga system run time library.
Copyright (c) 1998-2003 by Nils Sjoholm
member of the Amiga RTL development team.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{
History:
Added the defines use_amiga_smartlink and
use_auto_openlib. Implemented autoopening
of the library.
14 Jan 2003.
Update for AmigaOS 3.9.
Changed start code for unit.
06 Feb 2003.
Changed integer > smallint,
cardinal > longword.
09 Feb 2003.
nils.sjoholm@mailbox.swipnet.se
}
{$I useamigasmartlink.inc}
{$ifdef use_amiga_smartlink}
{$smartlink on}
{$endif use_amiga_smartlink}
UNIT layers;
INTERFACE
USES exec, graphics, utility;
const
LAYERSIMPLE = 1;
LAYERSMART = 2;
LAYERSUPER = 4;
LAYERUPDATING = $10;
LAYERBACKDROP = $40;
LAYERREFRESH = $80;
LAYER_CLIPRECTS_LOST = $100; { during BeginUpdate }
{ or during layerop }
{ this happens if out of memory }
LMN_REGION = -1;
type
pLayer_Info = ^tLayer_Info;
tLayer_Info = record
top_layer : pLayer;
check_lp : pLayer; { !! Private !! }
obs : pClipRect;
FreeClipRects : pClipRect; { !! Private !! }
PrivateReserve1, { !! Private !! }
PrivateReserve2 : Longint; { !! Private !! }
Lock : tSignalSemaphore; { !! Private !! }
gs_Head : tMinList; { !! Private !! }
PrivateReserve3 : smallint; { !! Private !! }
PrivateReserve4 : Pointer; { !! Private !! }
Flags : WORD;
fatten_count : Shortint; { !! Private !! }
LockLayersCount : Shortint; { !! Private !! }
PrivateReserve5 : smallint; { !! Private !! }
BlankHook, { !! Private !! }
LayerInfo_extra : Pointer; { !! Private !! }
end;
const
NEWLAYERINFO_CALLED = 1;
{
* LAYERS_NOBACKFILL is the value needed to get no backfill hook
* LAYERS_BACKFILL is the value needed to get the default backfill hook
}
LAYERS_NOBACKFILL = 1;
LAYERS_BACKFILL = 0;
LAYERSNAME : PChar = 'layers.library';
VAR LayersBase : pLibrary;
FUNCTION BeginUpdate(l : pLayer) : LONGINT;
FUNCTION BehindLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
FUNCTION CreateBehindHookLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; hook : pHook; bm2 : pBitMap) : pLayer;
FUNCTION CreateBehindLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; bm2 : pBitMap) : pLayer;
FUNCTION CreateUpfrontHookLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; hook : pHook; bm2 : pBitMap) : pLayer;
FUNCTION CreateUpfrontLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; bm2 : pBitMap) : pLayer;
FUNCTION DeleteLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
PROCEDURE DisposeLayerInfo(li : pLayer_Info);
PROCEDURE DoHookClipRects(hook : pHook; rport : pRastPort;const rect : pRectangle);
PROCEDURE EndUpdate(layer : pLayer; flag : ULONG);
FUNCTION FattenLayerInfo(li : pLayer_Info) : LONGINT;
PROCEDURE InitLayers(li : pLayer_Info);
FUNCTION InstallClipRegion(layer : pLayer;const region : pRegion) : pRegion;
FUNCTION InstallLayerHook(layer : pLayer; hook : pHook) : pHook;
FUNCTION InstallLayerInfoHook(li : pLayer_Info;const hook : pHook) : pHook;
PROCEDURE LockLayer(dummy : LONGINT; layer : pLayer);
PROCEDURE LockLayerInfo(li : pLayer_Info);
PROCEDURE LockLayers(li : pLayer_Info);
FUNCTION MoveLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT) : LONGINT;
FUNCTION MoveLayerInFrontOf(layer_to_move : pLayer; other_layer : pLayer) : LONGINT;
FUNCTION MoveSizeLayer(layer : pLayer; dx : LONGINT; dy : LONGINT; dw : LONGINT; dh : LONGINT) : LONGINT;
FUNCTION NewLayerInfo : pLayer_Info;
PROCEDURE ScrollLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT);
FUNCTION SizeLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT) : LONGINT;
PROCEDURE SortLayerCR(layer : pLayer; dx : LONGINT; dy : LONGINT);
PROCEDURE SwapBitsRastPortClipRect(rp : pRastPort; cr : pClipRect);
PROCEDURE ThinLayerInfo(li : pLayer_Info);
PROCEDURE UnlockLayer(layer : pLayer);
PROCEDURE UnlockLayerInfo(li : pLayer_Info);
PROCEDURE UnlockLayers(li : pLayer_Info);
FUNCTION UpfrontLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
FUNCTION WhichLayer(li : pLayer_Info; x : LONGINT; y : LONGINT) : pLayer;
{Here we read how to compile this unit}
{You can remove this include and use a define instead}
{$I useautoopenlib.inc}
{$ifdef use_init_openlib}
procedure InitLAYERSLibrary;
{$endif use_init_openlib}
{This is a variable that knows how the unit is compiled}
var
LAYERSIsCompiledHow : longint;
IMPLEMENTATION
uses
{$ifndef dont_use_openlib}
msgbox;
{$endif dont_use_openlib}
FUNCTION BeginUpdate(l : pLayer) : LONGINT;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L l,A0
MOVEA.L LayersBase,A6
JSR -078(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION BehindLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L dummy,A0
MOVEA.L layer,A1
MOVEA.L LayersBase,A6
JSR -054(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION CreateBehindHookLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; hook : pHook; bm2 : pBitMap) : pLayer;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L bm,A1
MOVE.L x0,D0
MOVE.L y0,D1
MOVE.L x1,D2
MOVE.L y1,D3
MOVE.L flags,D4
MOVEA.L hook,A3
MOVEA.L bm2,A2
MOVEA.L LayersBase,A6
JSR -192(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION CreateBehindLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; bm2 : pBitMap) : pLayer;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L bm,A1
MOVE.L x0,D0
MOVE.L y0,D1
MOVE.L x1,D2
MOVE.L y1,D3
MOVE.L flags,D4
MOVEA.L bm2,A2
MOVEA.L LayersBase,A6
JSR -042(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION CreateUpfrontHookLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; hook : pHook; bm2 : pBitMap) : pLayer;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L bm,A1
MOVE.L x0,D0
MOVE.L y0,D1
MOVE.L x1,D2
MOVE.L y1,D3
MOVE.L flags,D4
MOVEA.L hook,A3
MOVEA.L bm2,A2
MOVEA.L LayersBase,A6
JSR -186(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION CreateUpfrontLayer(li : pLayer_Info; bm : pBitMap; x0 : LONGINT; y0 : LONGINT; x1 : LONGINT; y1 : LONGINT; flags : LONGINT; bm2 : pBitMap) : pLayer;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L bm,A1
MOVE.L x0,D0
MOVE.L y0,D1
MOVE.L x1,D2
MOVE.L y1,D3
MOVE.L flags,D4
MOVEA.L bm2,A2
MOVEA.L LayersBase,A6
JSR -036(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION DeleteLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L dummy,A0
MOVEA.L layer,A1
MOVEA.L LayersBase,A6
JSR -090(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
PROCEDURE DisposeLayerInfo(li : pLayer_Info);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L LayersBase,A6
JSR -150(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE DoHookClipRects(hook : pHook; rport : pRastPort;const rect : pRectangle);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L hook,A0
MOVEA.L rport,A1
MOVEA.L rect,A2
MOVEA.L LayersBase,A6
JSR -216(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE EndUpdate(layer : pLayer; flag : ULONG);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L layer,A0
MOVE.L flag,D0
MOVEA.L LayersBase,A6
JSR -084(A6)
MOVEA.L (A7)+,A6
END;
END;
FUNCTION FattenLayerInfo(li : pLayer_Info) : LONGINT;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L LayersBase,A6
JSR -156(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
PROCEDURE InitLayers(li : pLayer_Info);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L LayersBase,A6
JSR -030(A6)
MOVEA.L (A7)+,A6
END;
END;
FUNCTION InstallClipRegion(layer : pLayer;const region : pRegion) : pRegion;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L layer,A0
MOVEA.L region,A1
MOVEA.L LayersBase,A6
JSR -174(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION InstallLayerHook(layer : pLayer; hook : pHook) : pHook;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L layer,A0
MOVEA.L hook,A1
MOVEA.L LayersBase,A6
JSR -198(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION InstallLayerInfoHook(li : pLayer_Info;const hook : pHook) : pHook;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L hook,A1
MOVEA.L LayersBase,A6
JSR -204(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
PROCEDURE LockLayer(dummy : LONGINT; layer : pLayer);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L dummy,A0
MOVEA.L layer,A1
MOVEA.L LayersBase,A6
JSR -096(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE LockLayerInfo(li : pLayer_Info);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L LayersBase,A6
JSR -120(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE LockLayers(li : pLayer_Info);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L LayersBase,A6
JSR -108(A6)
MOVEA.L (A7)+,A6
END;
END;
FUNCTION MoveLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT) : LONGINT;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L dummy,A0
MOVEA.L layer,A1
MOVE.L dx,D0
MOVE.L dy,D1
MOVEA.L LayersBase,A6
JSR -060(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION MoveLayerInFrontOf(layer_to_move : pLayer; other_layer : pLayer) : LONGINT;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L layer_to_move,A0
MOVEA.L other_layer,A1
MOVEA.L LayersBase,A6
JSR -168(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION MoveSizeLayer(layer : pLayer; dx : LONGINT; dy : LONGINT; dw : LONGINT; dh : LONGINT) : LONGINT;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L layer,A0
MOVE.L dx,D0
MOVE.L dy,D1
MOVE.L dw,D2
MOVE.L dh,D3
MOVEA.L LayersBase,A6
JSR -180(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION NewLayerInfo : pLayer_Info;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L LayersBase,A6
JSR -144(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
PROCEDURE ScrollLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L dummy,A0
MOVEA.L layer,A1
MOVE.L dx,D0
MOVE.L dy,D1
MOVEA.L LayersBase,A6
JSR -072(A6)
MOVEA.L (A7)+,A6
END;
END;
FUNCTION SizeLayer(dummy : LONGINT; layer : pLayer; dx : LONGINT; dy : LONGINT) : LONGINT;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L dummy,A0
MOVEA.L layer,A1
MOVE.L dx,D0
MOVE.L dy,D1
MOVEA.L LayersBase,A6
JSR -066(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
PROCEDURE SortLayerCR(layer : pLayer; dx : LONGINT; dy : LONGINT);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L layer,A0
MOVE.L dx,D0
MOVE.L dy,D1
MOVEA.L LayersBase,A6
JSR -210(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE SwapBitsRastPortClipRect(rp : pRastPort; cr : pClipRect);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L rp,A0
MOVEA.L cr,A1
MOVEA.L LayersBase,A6
JSR -126(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE ThinLayerInfo(li : pLayer_Info);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L LayersBase,A6
JSR -162(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE UnlockLayer(layer : pLayer);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L layer,A0
MOVEA.L LayersBase,A6
JSR -102(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE UnlockLayerInfo(li : pLayer_Info);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L LayersBase,A6
JSR -138(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE UnlockLayers(li : pLayer_Info);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVEA.L LayersBase,A6
JSR -114(A6)
MOVEA.L (A7)+,A6
END;
END;
FUNCTION UpfrontLayer(dummy : LONGINT; layer : pLayer) : LONGINT;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L dummy,A0
MOVEA.L layer,A1
MOVEA.L LayersBase,A6
JSR -048(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION WhichLayer(li : pLayer_Info; x : LONGINT; y : LONGINT) : pLayer;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L li,A0
MOVE.L x,D0
MOVE.L y,D1
MOVEA.L LayersBase,A6
JSR -132(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
const
{ Change VERSION and LIBVERSION to proper values }
VERSION : string[2] = '0';
LIBVERSION : longword = 0;
{$ifdef use_init_openlib}
{$Info Compiling initopening of layers.library}
{$Info don't forget to use InitLAYERSLibrary in the beginning of your program}
var
layers_exit : Pointer;
procedure CloselayersLibrary;
begin
ExitProc := layers_exit;
if LayersBase <> nil then begin
CloseLibrary(LayersBase);
LayersBase := nil;
end;
end;
procedure InitLAYERSLibrary;
begin
LayersBase := nil;
LayersBase := OpenLibrary(LAYERSNAME,LIBVERSION);
if LayersBase <> nil then begin
layers_exit := ExitProc;
ExitProc := @CloselayersLibrary;
end else begin
MessageBox('FPC Pascal Error',
'Can''t open layers.library version ' + VERSION + #10 +
'Deallocating resources and closing down',
'Oops');
halt(20);
end;
end;
begin
LAYERSIsCompiledHow := 2;
{$endif use_init_openlib}
{$ifdef use_auto_openlib}
{$Info Compiling autoopening of layers.library}
var
layers_exit : Pointer;
procedure CloselayersLibrary;
begin
ExitProc := layers_exit;
if LayersBase <> nil then begin
CloseLibrary(LayersBase);
LayersBase := nil;
end;
end;
begin
LayersBase := nil;
LayersBase := OpenLibrary(LAYERSNAME,LIBVERSION);
if LayersBase <> nil then begin
layers_exit := ExitProc;
ExitProc := @CloselayersLibrary;
LAYERSIsCompiledHow := 1;
end else begin
MessageBox('FPC Pascal Error',
'Can''t open layers.library version ' + VERSION + #10 +
'Deallocating resources and closing down',
'Oops');
halt(20);
end;
{$endif use_auto_openlib}
{$ifdef dont_use_openlib}
begin
LAYERSIsCompiledHow := 3;
{$Warning No autoopening of layers.library compiled}
{$Warning Make sure you open layers.library yourself}
{$endif dont_use_openlib}
END. (* UNIT LAYERS *)
|