3 #include <intuition/intuition.h>
4 #include <graphics/gfx.h>
5 #include <cybergraphx/cybergraphics.h>
6 #include <proto/exec.h>
8 #include <proto/graphics.h>
9 #include <proto/cybergraphics.h>
10 #include <proto/intuition.h>
19 /***********************************************************************************/
21 struct IntuitionBase
*IntuitionBase
;
22 struct GfxBase
*GfxBase
;
23 struct Library
*CyberGfxBase
;
27 ULONG cgfx_coltab
[256];
28 UBYTE remaptable
[256];
30 WORD winx
= -1, winy
= -1;
32 BOOL forcescreen
, forcewindow
;
33 BOOL mustremap
, truecolor
, remapped
, wbscreen
= TRUE
;
35 /***********************************************************************************/
40 /***********************************************************************************/
42 static unsigned char *scr1
;
43 static unsigned char *scr2
;
44 static unsigned char *scr_remapped
;
54 for ( bcl
=0 ; bcl
<3*W
; bcl
++ )
55 *(scr2
+W
*H
+bcl
) = 56 + rand()%40;
58 for ( bcl
=0 ; bcl
<tmp
; bcl
++ )
60 dst
= scr2
+ W
*(H
+1) + rand()%(W
-3);
76 for ( bcl
=0 ; bcl
<W
*(H
+2)-2 ; bcl
++ )
101 WriteLUTPixelArray(scr1
,
117 UBYTE
*dest
= scr_remapped
;
119 for(i
= 0; i
< W
* H
; i
++)
121 *dest
++ = remaptable
[*src
++];
123 WriteChunkyPixels(rp
,
126 win
->BorderLeft
+ W
- 1,
127 win
->BorderTop
+ H
- 1,
134 WriteChunkyPixels(rp
,
137 win
->BorderLeft
+ W
- 1,
138 win
->BorderTop
+ H
- 1,
144 void init_colormap() {
149 for ( i
=0 ; i
<256 ; i
++ )
153 if ( (i
> 7) && (i
< 32) )
158 if ( (i
> 32 ) && (i
< 57 ) )
165 if ( (i
> 7) && (i
< 17) )
167 if ( (i
> 57) && (i
< 82) )
174 cgfx_coltab
[i
] = (r
<<16) + (g
<<8) + (b
);
178 ULONG red
= r
* 0x01010101;
179 ULONG green
= g
* 0x01010101;
180 ULONG blue
= b
* 0x01010101;
182 remaptable
[i
] = ObtainBestPen(scr
->ViewPort
.ColorMap
,
186 OBP_Precision
, PRECISION_IMAGE
,
187 OBP_FailIfBad
, FALSE
,
194 ULONG red
= r
* 0x01010101;
195 ULONG green
= g
* 0x01010101;
196 ULONG blue
= b
* 0x01010101;
198 SetRGB32(&scr
->ViewPort
, i
, red
, green
, blue
);
205 /***********************************************************************************/
207 static void cleanup(char *msg
)
212 printf("Flamme: %s\n",msg
);
215 if (win
) CloseWindow(win
);
221 for(i
= 0; i
< 256; i
++)
223 ReleasePen(scr
->ViewPort
.ColorMap
, remaptable
[i
]);
230 UnlockPubScreen(0, scr
);
235 if (CyberGfxBase
) CloseLibrary(CyberGfxBase
);
236 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
237 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
242 /***********************************************************************************/
244 #define ARG_TEMPLATE "WINPOSX=X/N/K,WINPOSY=Y/N/K,FORCESCREEN=SCR/S,FORCEWINDOW=WIN/S"
251 static IPTR args
[NUM_ARGS
];
253 static void getarguments(void)
255 struct RDArgs
*myargs
;
257 if ((myargs
= ReadArgs(ARG_TEMPLATE
, args
, NULL
)))
261 else if (args
[ARG_WIN
])
264 if (args
[ARG_X
]) winx
= *(IPTR
*)args
[ARG_X
];
265 if (args
[ARG_Y
]) winy
= *(IPTR
*)args
[ARG_Y
];
271 /***********************************************************************************/
273 static void openlibs(void)
275 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39)))
277 cleanup("Can't open intuition.library V39!");
280 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 39)))
282 cleanup("Can't open graphics.library V39!");
285 if (!(CyberGfxBase
= OpenLibrary("cybergraphics.library",0)))
287 cleanup("Can't open cybergraphics.library!");
292 /***********************************************************************************/
294 static void getvisual(void)
296 if (!(scr
= LockPubScreen(NULL
)))
298 cleanup("Can't lock pub screen!");
301 if (GetBitMapAttr(scr
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
313 if (forcescreen
) wbscreen
= FALSE
;
317 UnlockPubScreen(NULL
, scr
);
320 scr
= OpenScreenTags(NULL
, SA_Width
, W
,
324 if (!scr
) cleanup("Can't open screen!");
327 truecolor
= (GetBitMapAttr(scr
->RastPort
.BitMap
, BMA_DEPTH
) >= 15) ? TRUE
: FALSE
;
330 /***********************************************************************************/
332 static void makewin(void)
334 struct TagItem winonwbtags
[] =
336 {WA_DragBar
, TRUE
},
337 {WA_DepthGadget
, TRUE
},
338 {WA_CloseGadget
, TRUE
},
339 {WA_Title
, (IPTR
)"Flamme" },
343 struct TagItem winonscrtags
[] =
345 {WA_Borderless
, TRUE
},
349 if (winx
== -1) winx
= (scr
->Width
- W
- scr
->WBorLeft
- scr
->WBorRight
) / 2;
350 if (winy
== -1) winy
= (scr
->Height
- H
- scr
->WBorTop
- scr
->WBorTop
- scr
->Font
->ta_YSize
- 1) / 2;
352 win
= OpenWindowTags(NULL
, WA_CustomScreen
, (IPTR
)scr
,
357 WA_AutoAdjust
, TRUE
,
359 WA_IDCMP
, IDCMP_CLOSEWINDOW
|
361 TAG_MORE
, wbscreen
? (IPTR
) winonwbtags
: (IPTR
) winonscrtags
);
364 if (!win
) cleanup("Can't open window");
369 /***********************************************************************************/
372 #define KC_RIGHT 0x4E
377 /***********************************************************************************/
379 static void getevents(void)
381 struct IntuiMessage
*msg
;
383 while ((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
387 case IDCMP_CLOSEWINDOW
:
393 WORD code
= msg
->Code
& ~IECODE_UP_PREFIX
;
395 Keys
[code
] = (code
== msg
->Code
) ? 1 : 0;
401 ReplyMsg((struct Message
*)msg
);
406 /***********************************************************************************/
408 static void action(void)
412 scr1
= (unsigned char *) calloc ( W
*(H
+4) , 1 );
413 scr2
= (unsigned char *) calloc ( W
*(H
+4) , 1 );
415 if (!scr1
|| !scr2
) cleanup("Out of memory!");
419 scr_remapped
= (unsigned char *) calloc (W
* H
, 1);
420 if (!scr_remapped
) cleanup("Out of memory!");
430 while (!Keys
[KC_ESC
])
444 /***********************************************************************************/
458 /***********************************************************************************/