1 #include <exec/memory.h>
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>
16 #define SCREENWIDTH 300
17 #define SCREENHEIGHT 200
18 #define SCREENCY (SCREENHEIGHT / 2)
20 /***********************************************************************************/
22 struct IntuitionBase
*IntuitionBase
;
23 struct GfxBase
*GfxBase
;
24 struct Library
*CyberGfxBase
;
29 ULONG cgfx_coltab
[256];
32 /***********************************************************************************/
34 static void cleanup(char *msg
)
38 printf("WritePixelArray: %s\n",msg
);
41 if (win
) CloseWindow(win
);
43 if (scr
) UnlockPubScreen(0, scr
);
45 if (CyberGfxBase
) CloseLibrary(CyberGfxBase
);
46 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
47 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
52 /***********************************************************************************/
54 static void openlibs(void)
56 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39)))
58 cleanup("Can't open intuition.library V39!");
61 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 39)))
63 cleanup("Can't open graphics.library V39!");
66 if (!(CyberGfxBase
= OpenLibrary("cybergraphics.library",0)))
68 cleanup("Can't open cybergraphics.library!");
72 /***********************************************************************************/
74 static void getvisual(void)
76 if (!(scr
= LockPubScreen(NULL
)))
78 cleanup("Can't lock pub screen!");
85 val
= GetCyberMapAttr(scr
->RastPort
.BitMap
,CYBRMATTR_PIXFMT
);
87 printf("cgfx attribute = %ld\n", val
);
90 if (GetBitMapAttr(scr
->RastPort
.BitMap
, BMA_DEPTH
) <= 8)
92 cleanup("Need hi or true color screen!");
97 /***********************************************************************************/
99 static void makewin(void)
101 win
= OpenWindowTags(NULL
, WA_CustomScreen
, (IPTR
)scr
,
102 WA_InnerWidth
, SCREENWIDTH
,
103 WA_InnerHeight
, SCREENHEIGHT
,
104 WA_Title
, (IPTR
)"ReadPixelArray",
106 WA_DepthGadget
, TRUE
,
107 WA_CloseGadget
, TRUE
,
109 WA_BackFill
, (IPTR
)LAYERS_NOBACKFILL
,
110 WA_IDCMP
, IDCMP_CLOSEWINDOW
|
114 if (!win
) cleanup("Can't open window");
119 /***********************************************************************************/
122 #define KC_RIGHT 0x4E
127 /***********************************************************************************/
129 static void getevents(void)
131 struct IntuiMessage
*msg
;
133 while ((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
137 case IDCMP_CLOSEWINDOW
:
143 WORD code
= msg
->Code
& ~IECODE_UP_PREFIX
;
145 Keys
[code
] = (code
== msg
->Code
) ? 1 : 0;
151 ReplyMsg((struct Message
*)msg
);
156 /***********************************************************************************/
158 static void action(void)
160 UBYTE
*buf
= AllocVec(SCREENWIDTH
* SCREENHEIGHT
* sizeof(ULONG
), MEMF_PUBLIC
);
168 SCREENWIDTH
* sizeof(ULONG
),
176 for(i
= 0; i
< SCREENWIDTH
* SCREENHEIGHT
* 4; i
+= 4)
186 SCREENWIDTH
* sizeof(ULONG
),
196 while (!Keys
[KC_ESC
])
198 WaitPort(win
->UserPort
);
201 } /* while(!Keys[KC_ESC]) */
207 /***********************************************************************************/
217 return 0; /* keep compiler happy */
220 /***********************************************************************************/