2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
6 #include <exec/memory.h>
8 #include <intuition/intuition.h>
9 #include <graphics/gfx.h>
10 #include <cybergraphx/cybergraphics.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include <proto/graphics.h>
14 #include <proto/cybergraphics.h>
15 #include <proto/intuition.h>
21 #define SCREENWIDTH 300
22 #define SCREENHEIGHT 200
23 #define SCREENCY (SCREENHEIGHT / 2)
25 /***********************************************************************************/
27 struct IntuitionBase
*IntuitionBase
;
28 struct GfxBase
*GfxBase
;
29 struct Library
*CyberGfxBase
;
34 ULONG cgfx_coltab
[256];
37 /***********************************************************************************/
39 static void cleanup(char *msg
)
43 printf("WritePixelArray: %s\n",msg
);
46 if (win
) CloseWindow(win
);
48 if (scr
) UnlockPubScreen(0, scr
);
50 if (CyberGfxBase
) CloseLibrary(CyberGfxBase
);
51 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
52 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
57 /***********************************************************************************/
59 static void openlibs(void)
61 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39)))
63 cleanup("Can't open intuition.library V39!");
66 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 39)))
68 cleanup("Can't open graphics.library V39!");
71 if (!(CyberGfxBase
= OpenLibrary("cybergraphics.library",0)))
73 cleanup("Can't open cybergraphics.library!");
77 /***********************************************************************************/
79 static void getvisual(void)
81 if (!(scr
= LockPubScreen(NULL
)))
83 cleanup("Can't lock pub screen!");
90 val
= GetCyberMapAttr(scr
->RastPort
.BitMap
,CYBRMATTR_PIXFMT
);
92 printf("cgfx attribute = %ld\n", (long)val
);
95 if (GetBitMapAttr(scr
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
97 cleanup("Need hi or true color screen!");
102 /***********************************************************************************/
104 static void makewin(void)
106 win
= OpenWindowTags(NULL
, WA_CustomScreen
, (IPTR
)scr
,
107 WA_InnerWidth
, SCREENWIDTH
,
108 WA_InnerHeight
, SCREENHEIGHT
,
109 WA_Title
, (IPTR
)"ReadPixelArray",
111 WA_DepthGadget
, TRUE
,
112 WA_CloseGadget
, TRUE
,
114 WA_BackFill
, (IPTR
)LAYERS_NOBACKFILL
,
115 WA_IDCMP
, IDCMP_CLOSEWINDOW
|
119 if (!win
) cleanup("Can't open window");
124 /***********************************************************************************/
127 #define KC_RIGHT 0x4E
132 /***********************************************************************************/
134 static void getevents(void)
136 struct IntuiMessage
*msg
;
138 while ((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
142 case IDCMP_CLOSEWINDOW
:
148 WORD code
= msg
->Code
& ~IECODE_UP_PREFIX
;
150 Keys
[code
] = (code
== msg
->Code
) ? 1 : 0;
156 ReplyMsg((struct Message
*)msg
);
161 /***********************************************************************************/
163 static void action(void)
165 UBYTE
*buf
= AllocVec(SCREENWIDTH
* SCREENHEIGHT
* sizeof(ULONG
), MEMF_PUBLIC
);
173 SCREENWIDTH
* sizeof(ULONG
),
181 for(i
= 0; i
< SCREENWIDTH
* SCREENHEIGHT
* 4; i
+= 4)
191 SCREENWIDTH
* sizeof(ULONG
),
201 while (!Keys
[KC_ESC
])
203 WaitPort(win
->UserPort
);
206 } /* while(!Keys[KC_ESC]) */
211 /***********************************************************************************/
221 return 0; /* keep compiler happy */
224 /***********************************************************************************/