added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / demos / compleximage.c
blob17a8d16e4f23320c34714273a7835ee1f074cce1
1 ;/* compleximage.c - program to show the use of a complex Intuition Image.
2 lc -b1 -cfist -v -y -j73 compleximage.c
3 blink FROM LIB:c.o compleximage.o TO compleximage LIB LIB:lc.lib LIB:amiga.lib
4 quit
5 */
7 /*
8 Copyright (c) 1992 Commodore-Amiga, Inc.
10 This example is provided in electronic form by Commodore-Amiga, Inc. for
11 use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
12 published by Addison-Wesley (ISBN 0-201-56774-1).
14 The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
15 information on the correct usage of the techniques and operating system
16 functions presented in these examples. The source and executable code
17 of these examples may only be distributed in free electronic form, via
18 bulletin board or as part of a fully non-commercial and freely
19 redistributable diskette. Both the source and executable code (including
20 comments) must be included, without modification, in any copy. This
21 example may not be published in printed form or distributed with any
22 commercial product. However, the programming techniques and support
23 routines set forth in these examples may be used in the development
24 of original executable software products for Commodore Amiga computers.
26 All other rights reserved.
28 This example is provided "as-is" and is subject to change; no
29 warranties are made. All use is at your own risk. No liability or
30 responsibility is assumed.
34 #define INTUI_V36_NAMES_ONLY
36 #include <exec/types.h>
37 #include <intuition/intuition.h>
38 #include <intuition/intuitionbase.h>
40 #include <proto/exec.h>
41 #include <proto/dos.h>
42 #include <proto/intuition.h>
44 #include <stdio.h>
46 static const char version[] = "$VER: compleximage 41.1 (14.3.1997)\n";
48 #ifdef __AROS__
49 #ifdef __chip
50 #undef __chip
51 #endif
52 #define __chip
53 #include <proto/alib.h>
54 #endif
56 #ifdef LATTICE
57 int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
58 int chkabort(void) { return(0); } /* really */
59 #endif
61 struct IntuitionBase *IntuitionBase = NULL;
63 #define MYIMAGE_LEFT (0)
64 #define MYIMAGE_TOP (0)
65 #define MYIMAGE_WIDTH (24)
66 #define MYIMAGE_HEIGHT (10)
67 #define MYIMAGE_DEPTH (2)
69 /* This is the image data. It is a two bitplane open rectangle which
70 ** is 24 pixels wide and 10 high. Make sure that it is in CHIP memory,
71 ** or allocate a block of chip memory with a call like:
73 ** AllocMem(data_size,MEMF_CHIP)
75 ** and copy the data to that block. See the Exec chapter on
76 ** Memory Allocation for more information on AllocMem().
78 UWORD __chip myImageData[] =
80 /* first bitplane of data,
81 ** open rectangle.
83 0xFFFF, 0xFF00,
84 0xC000, 0x0300,
85 0xC000, 0x0300,
86 0xC000, 0x0300,
87 0xC000, 0x0300,
88 0xC000, 0x0300,
89 0xC000, 0x0300,
90 0xC000, 0x0300,
91 0xC000, 0x0300,
92 0xFFFF, 0xFF00,
94 /* second bitplane of data,
95 ** filled rectangle to appear within open rectangle.
97 0x0000, 0x0000,
98 0x0000, 0x0000,
99 0x0000, 0x0000,
100 0x00FF, 0x0000,
101 0x00FF, 0x0000,
102 0x00FF, 0x0000,
103 0x00FF, 0x0000,
104 0x0000, 0x0000,
105 0x0000, 0x0000,
106 0x0000, 0x0000,
109 /* used to get the "new look" on a custom screen */
110 UWORD pens[] = { ~0 };
114 ** main routine. Open required library and window and draw the images.
115 ** This routine opens a very simple window with no IDCMP. See the
116 ** chapters on "Windows" and "Input and Output Methods" for more info.
117 ** Free all resources when done.
119 int main(int argc, char *argv[])
121 struct Screen *scr;
122 struct Window *win;
123 struct Image myImage;
125 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",37);
126 if (IntuitionBase != NULL)
128 if (NULL != (scr = OpenScreenTags(NULL,
129 SA_Depth, 4,
130 SA_Pens, (IPTR) &pens,
131 TAG_END)))
133 #ifdef __AROS__
134 if (NULL != (win = OpenWindowTags(NULL,
135 WA_RMBTrap, TRUE,
136 WA_CustomScreen, (IPTR) scr,
137 WA_IDCMP, IDCMP_RAWKEY,
138 TAG_END)))
139 #else
140 if (NULL != (win = OpenWindowTags(NULL,
141 WA_RMBTrap, TRUE,
142 WA_CustomScreen, scr,
143 TAG_END)))
144 #endif
146 myImage.LeftEdge = MYIMAGE_LEFT;
147 myImage.TopEdge = MYIMAGE_TOP;
148 myImage.Width = MYIMAGE_WIDTH;
149 myImage.Height = MYIMAGE_HEIGHT;
150 myImage.Depth = MYIMAGE_DEPTH;
151 myImage.ImageData = myImageData;
152 myImage.PlanePick = 0x3; /* use first two bitplanes */
153 myImage.PlaneOnOff = 0x0; /* clear all unused planes */
154 myImage.NextImage = NULL;
156 /* Draw the image into the first two bitplanes */
157 DrawImage(win->RPort,&myImage,10,10);
159 /* Draw the same image at a new location */
160 DrawImage(win->RPort,&myImage,100,10);
162 /* Change the image to use the second and fourth bitplanes,
163 ** PlanePick is 1010 binary or 0xA,
164 ** and draw it again at a different location
166 myImage.PlanePick = 0xA;
167 DrawImage(win->RPort,&myImage,10,50);
169 /* Now set all the bits in the first bitplane with PlaneOnOff.
170 ** This will make all the bits set in the second bitplane
171 ** appear as color 3 (0011 binary), all the bits set in the
172 ** fourth bitplane appear as color 9 (1001 binary) and all
173 ** other pixels will be color 1 (0001 binary. If there were
174 ** any points in the image where both bits were set, they
175 ** would appear as color 11 (1011 binary).
176 ** Draw the image at a different location.
178 myImage.PlaneOnOff = 0x1;
179 DrawImage(win->RPort,&myImage,100,50);
181 #ifdef __AROS__
182 /* Wait for a keypress */
183 Wait (1L << win->UserPort->mp_SigBit);
184 #else
185 /* Wait a bit, then quit.
186 ** In a real application, this would be an event loop, like the
187 ** one described in the Intuition Input and Output Methods chapter.
189 Delay(200);
190 #endif
192 CloseWindow(win);
194 CloseScreen(scr);
196 CloseLibrary((struct Library *)IntuitionBase);
198 return 0;