Initial import of Scalos. To decrease size I have
[AROS-Contrib.git] / fish / 362_rubik / getwindow.c
blob12a4bacfd1c1486473ed0eb6a1392bc6a8dde6b0
1 /************************************************************
3 * getwindow.c ......used in rubik.c
4 *
6 * M.J.R. 19/12/89
8 *************************************************************/
10 #include "header.c"
12 struct IntuitionBase *IntuitionBase = NULL;
13 struct GfxBase *GfxBase = NULL;
14 struct IntuiMessage *MyIntuiMessage = NULL;
16 extern struct Screen *scr1, *scr2;
17 extern struct Gadget divegadget;
18 extern struct TextAttr ta;
20 struct NewScreen ns =
22 0, /* left edge - should be zero */
23 0, /* top edge */
24 320, /* width - low resolution */
25 200, /* height - non-interlace */
26 3, /* depth - 8 colours will be available */
27 0,7, /* detail pen and block pen specifications */
28 0, /* display mode */
29 CUSTOMSCREEN, /* the screen type */
30 &ta, /* font */
31 NULL, /* no default title */
32 NULL, /* no special screen gadgets */
33 NULL, /* no special custom bitmap */
36 extern struct Window *wnd1, *wnd2;
38 struct NewWindow nw =
40 0,0,320,199, /* position and size */
41 0,7, /* pens */
42 CLOSEWINDOW |
43 GADGETUP |
44 MOUSEBUTTONS, /* IDCMPFlags */
45 WINDOWCLOSE |
46 BORDERLESS |
47 ACTIVATE |
48 RMBTRAP, /* flags */
49 &divegadget, /* gadgets */
50 NULL, /* no special checkmark */
51 NULL, /* no title! */
52 NULL, /* screen pointer */
53 NULL, /* no bitmap */
54 0,0, /* minimum sizes */
55 320,199, /* maximum sizes */
56 CUSTOMSCREEN /* type of screen */
59 WORD areabuffer[25]; /* room for up to a decagon */
61 struct TmpRas tmpras;
62 struct AreaInfo ai;
64 void MyCleanup()
66 if (wnd2)
67 CloseWindow(wnd2);
68 if (wnd1)
69 CloseWindow(wnd1);
70 if (scr2)
71 CloseScreen(scr2);
72 if (scr1)
73 CloseScreen(scr1);
74 if (GfxBase != NULL)
75 CloseLibrary((struct Library *) GfxBase);
76 if (IntuitionBase != NULL)
77 CloseLibrary((struct Library *) IntuitionBase);
80 void cleanup()
82 FreeRaster(tmpras.RasPtr,320,199);
83 MyCleanup();
86 void getwindow()
88 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
89 if (IntuitionBase == NULL)
91 MyCleanup();
92 exit(FALSE);
95 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0);
96 if (GfxBase == NULL)
98 MyCleanup();
99 exit(FALSE);
102 scr1 = (struct Screen *)OpenScreen(&ns);
103 if (scr1 == NULL)
105 MyCleanup();
106 exit(FALSE);
109 scr2 = (struct Screen *)OpenScreen(&ns);
110 if (scr1 == NULL)
112 MyCleanup();
113 exit(FALSE);
116 SetRGB4(&(scr1->ViewPort),1,14,12,2); /* y */
117 SetRGB4(&(scr1->ViewPort),2,13,13,13); /* w */
118 SetRGB4(&(scr1->ViewPort),3,0,10,0); /* g */
119 SetRGB4(&(scr1->ViewPort),4,2,4,11); /* bu */
120 SetRGB4(&(scr1->ViewPort),5,15,5,0); /* o */
121 SetRGB4(&(scr1->ViewPort),6,11,3,1); /* bn */
122 SetRGB4(&(scr1->ViewPort),7,10,10,10); /* gy */
123 SetRGB4(&(scr1->ViewPort),0,0,0,0); /* bk */
125 SetRGB4(&(scr2->ViewPort),1,14,12,2); /* y */
126 SetRGB4(&(scr2->ViewPort),2,13,13,13); /* w */
127 SetRGB4(&(scr2->ViewPort),3,0,10,0); /* g */
128 SetRGB4(&(scr2->ViewPort),4,2,4,11); /* bu */
129 SetRGB4(&(scr2->ViewPort),5,15,5,0); /* o */
130 SetRGB4(&(scr2->ViewPort),6,11,3,1); /* bn */
131 SetRGB4(&(scr2->ViewPort),7,10,10,10); /* gy */
132 SetRGB4(&(scr2->ViewPort),0,0,0,0); /* bk */
134 nw.Screen = scr1; /* fix the pointer into the struct */
136 wnd1 = (struct Window *)OpenWindow(&nw);
137 if (wnd1 == NULL)
139 MyCleanup();
140 exit(FALSE);
143 nw.Screen = scr2; /* fix the pointer into the struct */
145 wnd2 = (struct Window *)OpenWindow(&nw);
146 if (wnd2 == NULL)
148 MyCleanup();
149 exit(FALSE);
152 InitArea(&ai,&(areabuffer[0]),10);
154 InitTmpRas(&tmpras,AllocRaster(320,199),RASSIZE(320,199));
156 wnd1->RPort->AreaInfo = &ai;
158 wnd1->RPort->TmpRas = &tmpras;
159 wnd2->RPort->AreaInfo = &ai;
160 wnd2->RPort->TmpRas = wnd1->RPort->TmpRas;
162 SetAPen(wnd2->RPort,7);
163 SetDrMd(wnd2->RPort,JAM1);
164 Move(wnd2->RPort,197,31);
165 Draw(wnd2->RPort,197,23);
166 Draw(wnd2->RPort,237,23);
167 Move(wnd2->RPort,276,31);
168 Draw(wnd2->RPort,276,23);
169 Draw(wnd2->RPort,308,23);
170 Move(wnd2->RPort,199,90);
171 Draw(wnd2->RPort,199,82);
172 Draw(wnd2->RPort,248,82);
173 Draw(wnd2->RPort,248,90);
174 Move(wnd2->RPort,260,90);
175 Draw(wnd2->RPort,260,82);
176 Draw(wnd2->RPort,309,82);
177 Draw(wnd2->RPort,309,90);
178 Move(wnd2->RPort,270,115);
179 Draw(wnd2->RPort,301,115);
180 Move(wnd2->RPort,265,147);
181 Draw(wnd2->RPort,265,139);
182 Draw(wnd2->RPort,305,139);
184 RectFill(wnd2->RPort,206,101,244,112);
185 Move(wnd2->RPort,253,137);
186 Draw(wnd2->RPort,253,149);
187 Draw(wnd2->RPort,197,149);
188 Draw(wnd2->RPort,197,137);
189 Draw(wnd2->RPort,253,137);
190 Draw(wnd2->RPort,253,125);
191 Draw(wnd2->RPort,197,125);
192 Draw(wnd2->RPort,197,137);
193 Draw(wnd2->RPort,197,113);
194 Draw(wnd2->RPort,253,113);
195 Draw(wnd2->RPort,253,125);
197 Move(wnd2->RPort,210,110);
198 SetAPen(wnd2->RPort,0);
199 Text(wnd2->RPort,"MODE",4);
201 ClipBlit
203 wnd2->RPort,190,20,
204 wnd1->RPort,190,20,
205 128,177,
206 0xc0