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
|
**************************************************************************
** **
** CreateRastPort - Erstellt & initialisiert RastPort mit BitMaps **
** **
*+ Created: 12-Aug-88 CHW/CHH Last update: 25-Nov-89 CHW +*
*+ +*
**************************************************************************
** **
** Parameter : D0.W : Depth **
** D1.W : Width in Pixel **
** D2.W : Height in Pixel **
** **
** Resultat : D0.L : Zeiger auf RastPort oder 0 if failed **
** **
**************************************************************************
IDNT CreateRastPort
SECTION text,CODE
INCLUDE "exec/macros.i"
INCLUDE "exec/memory.i"
INCLUDE "exec/types.i"
INCLUDE "graphics/gfx.i"
INCLUDE "graphics/rastport.i"
XREF _GfxBase
XDEF @CreateRastPort,@DeleteRastPort
@CreateRastPort:
movem.l d1-d3/a0-a3/a5-a6,-(SP)
movem.l d0-d2,-(SP)
moveq.l #(rp_SIZEOF+bm_SIZEOF)/2,d0
add.l d0,d0 ; Optimierung...
moveq #MEMF_CLEAR>>16,d1
swap d1 ; Lattice C lässt grüssen
movea.l 4.W,a6
JSRLIB AllocMem
tst.l d0
bne.s 1$
lea 12(SP),SP ; Pop D0-D2
bra.s EndCreateRP ; No Mem --->
1$:
movea.l d0,a2 ; A2: RastPort
lea rp_SIZEOF(a2),a3 ; A3: BitMap
movea.l a2,a1 ; Rastport
movea.l _GfxBase,a6
JSRLIB InitRastPort
move.l a3,rp_BitMap(a2) ; BitMap in RastPort eintr.
movem.l (SP)+,d0-d2 ; Depth/Width/Height
movea.l a3,a0 ; BitMap
JSRLIB InitBitMap
move.w bm_BytesPerRow(a3),d2 ; Breite in Bytes
mulu.w bm_Rows(a3),d2 ; D2 := Länge einer plane
AllocPlanes: lea bm_Planes(a3),a5
moveq.l #0,d3
move.b bm_Depth(a3),d3 ; Anzahl Planes
bra.s 2$ ; für dbf
1$: move.l d2,d0 ; Amount
move.l #MEMF_CHIP+MEMF_CLEAR,d1
movea.l 4.W,a6
JSRLIB AllocMem
move.l d0,(a5)+ ; Plane eintragen
bne.s 2$ ; OK --->
movea.l a2,a0 ; RastPort
bsr @DeleteRastPort ; wieder freigeben
bra.s EndCreateRP ; und raus (D0 ist noch 0)
2$:
dbf d3,1$ ; ---> loop
move.l a2,d0 ; The RastPort
EndCreateRP:
movem.l (SP)+,d1-d3/a0-a3/a5-a6
rts
**************************************************************************
** **
** DeleteRastPort - Mit CreateRastPort() erstellten rp freigeben **
** **
** Parameter : A0.L : RastPort **
** **
**************************************************************************
@DeleteRastPort:
movem.l d0-d3/a0-a3/a5-a6,-(SP)
move.l a0,d0
beq.s EndDeleteRP
movea.l a0,a2 ; A2: RastPort
lea rp_SIZEOF(a2),a3 ; A3: BitMap
move.w bm_BytesPerRow(a3),d2 ; Breite in Bytes
mulu.w bm_Rows(a3),d2 ; D2 := Länge einer plane
FreePlanes: lea bm_Planes(a3),a5
moveq.l #0,d3
move.b bm_Depth(a3),d3 ; Anzahl Planes
bra.s 2$ ; für dbf
1$: move.l d2,d0 ; Amount
move.l (a5)+,d1 ; Nächste Plane
beq.s 2$ ; Null --->
movea.l d1,a1
movea.l 4.W,a6
JSRLIB FreeMem
2$: dbf d3,1$ ; ---> loop
movea.l a2,a1 ; RastPort & BitMap
moveq.l #(rp_SIZEOF+bm_SIZEOF)/2,d0
add.l d0,d0
JSRLIB FreeMem
EndDeleteRP:
movem.l (SP)+,d0-d3/a0-a3/a5-a6
rts
END
|