summaryrefslogtreecommitdiff
path: root/CreateRastPort.S
diff options
context:
space:
mode:
Diffstat (limited to 'CreateRastPort.S')
-rw-r--r--CreateRastPort.S121
1 files changed, 121 insertions, 0 deletions
diff --git a/CreateRastPort.S b/CreateRastPort.S
new file mode 100644
index 0000000..32ef457
--- /dev/null
+++ b/CreateRastPort.S
@@ -0,0 +1,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