3 #include <aros/oldprograms.h>
11 #include "gadgetdef.h"
14 struct Screen
*SurfScrn
= NULL
;
15 struct Window
*SurfWin
= NULL
;
16 struct Window
*CntrlWin
= NULL
;
17 struct Window
*GadWin
= NULL
;
19 * bit masks for waiting for signals
21 short CntrlSigBit
, SurfSigBit
, GadSigBit
;
27 struct GfxBase
*GfxBase
= 0;
28 struct IntuitionBase
*IntuitionBase
= 0;
34 int XOR
= COMPLEMENT
, /* so my other modules don't need to */
35 WRITE
= JAM1
; /* include so many amiga includes */
37 int WinHOrig
, WinVOrig
;
43 * data structures needed to use amiga polygons routines
45 static WORD PolyArea
[5*5];
46 static struct AreaInfo PolyInfo
;
47 static PLANEPTR PolyWorkSpace
;
48 static struct TmpRas PolyTmpRas
;
52 static void ResetWinDat() {
54 WinHOrig
= SurfWinDef
.Width
>>1;
55 WinVOrig
= SurfWinDef
.Height
>>1;
65 * open surface window/screen
68 NumColors
= 1 << SurfScrnDef
.Depth
;
69 ColorMax
= ( NumColors
-1) * DitherLevels
+ 1;
70 WinFgCol
= (NumColors
- 1) & 0x1f;
72 SurfScrnDef
.BlockPen
= ( WinFgCol
*3) /4;
73 SurfScrnDef
.DetailPen
= WinFgCol
>>2;
75 SurfScrn
= OpenScreen( &SurfScrnDef
);
77 SurfWinDef
.Screen
= GadWinDef
.Screen
= SurfScrn
;
78 SurfWinDef
.Width
= GadWinDef
.Width
= SurfScrnDef
.Width
;
79 SurfWinDef
.Height
= SurfScrnDef
.Height
- ButHeight
;
81 SurfWin
= OpenWindow( &SurfWinDef
);
82 GadWin
= OpenWindow( &GadWinDef
);
83 SurfSigBit
= SurfWin
->UserPort
->mp_SigBit
;
84 GadSigBit
= GadWin
->UserPort
->mp_SigBit
;
85 SignalMask
= (1<<CntrlSigBit
) | (1<<SurfSigBit
)| (1<<GadSigBit
);
88 ShowTitle( SurfScrn
, 0L ); /* hide screen title behind backdrop */
90 InitArea( &PolyInfo
, PolyArea
, 5);
91 rp
->AreaInfo
= &PolyInfo
;
93 PolyWorkSpace
= AllocRaster( SurfWinDef
.Width
, SurfWinDef
.Height
);
95 if( !PolyWorkSpace
) {
97 OutErr("no space for temporary rastern");
101 InitTmpRas( &PolyTmpRas
, PolyWorkSpace
,
102 RASSIZE( SurfWinDef
.Width
, SurfWinDef
.Height
));
103 rp
->TmpRas
= &PolyTmpRas
;
110 GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library",0);
112 OutErr("graphics library won't open");
116 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library",0);
117 if( IntuitionBase
== 0 ) {
118 OutErr("intuition library won't open");
123 CntrlWin
= OpenWindow( &CntrlWinDef
);
124 CntrlSigBit
= CntrlWin
->UserPort
->mp_SigBit
;
128 if( !SurfScrn
|| !SurfWin
|| !CntrlWin
) {
129 OutErr("couldn't open at least one window or screen");
134 SetMenuStrip(CntrlWin
, menu
);
139 * remove surface window/screen
144 FreeRaster( PolyWorkSpace
, SurfWinDef
.Width
, SurfWinDef
.Height
);
147 CloseWindow( SurfWin
);
150 CloseWindow( GadWin
);
153 CloseScreen( SurfScrn
);
164 ClearMenuStrip( CntrlWin
);
165 CloseWindow( CntrlWin
);
171 CloseLibrary((struct Library
*)IntuitionBase
);
174 CloseLibrary((struct Library
*)GfxBase
);