1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2013 by BetterString.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 BetterString class Support Site: http://www.sf.net/projects/bstring-mcc/
21 ***************************************************************************/
23 #include <exec/memory.h>
24 #include <exec/libraries.h>
25 #include <proto/graphics.h>
26 #include <proto/exec.h>
28 #include "SDI_compiler.h"
33 #define USE_OS3 (((struct Library *)GfxBase)->lib_Version >= 39)
36 struct BitMap
* SAVEDS ASM
MUIG_AllocBitMap(REG(d0
, LONG width
), REG(d1
, LONG height
), REG(d2
, LONG depth
), REG(d3
, LONG flags
), REG(a0
, struct BitMap
*friend))
38 #if defined(__amigaos4__)
39 return AllocBitMap(width
,height
,depth
,flags
,friend);
40 #elif defined(__MORPHOS__) || defined(__AROS__)
41 // FIXME: check if this is correct for AROS
42 return AllocBitMap(width
,height
,depth
,flags
|BMF_MINPLANES
|BMF_DISPLAYABLE
,friend);
48 // FindSemaphore() must be called in Forbid()den state
50 if(FindSemaphore((STRPTR
)"cybergraphics.library") != NULL
51 && (GetBitMapAttr(friend,BMA_FLAGS
) & BMF_INTERLEAVED
) == 0)
52 flags
|= BMF_MINPLANES
;
58 return AllocBitMap(width
,height
,depth
,flags
,friend);
62 struct BitMap
*bm
= AllocMem(sizeof(struct BitMap
), MEMF_CLEAR
);
66 int i
, plsize
=RASSIZE(width
,height
);
68 InitBitMap(bm
,depth
,width
,height
);
70 if((bm
->Planes
[0] = AllocVec(plsize
*depth
,(flags
& BMF_CLEAR
) ? MEMF_CHIP
|MEMF_CLEAR
: MEMF_CHIP
))) // !!!
73 bm
->Planes
[i
] = (PLANEPTR
)(((ULONG
)bm
->Planes
[i
-1]) + plsize
);
79 FreeMem(bm
,sizeof(struct BitMap
));
89 VOID SAVEDS ASM
MUIG_FreeBitMap(REG(a0
, struct BitMap
*bm
))
91 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
94 WaitBlit(); /* OCS/AGA require manual synchronisation */
102 FreeVec(bm
->Planes
[0]);
103 FreeMem(bm
,sizeof(struct BitMap
));