Here's a simple Commodore Amiga program in C that opens a basic window:
#include <exec/types.h>
#include <intuition/intuition.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
struct IntuitionBase *IntuitionBase;
struct Window *MyWindow;
static struct NewWindow NewWindowStructure = {
20, 20, /* window position */
300, 100, /* window size */
0, 1, /* detail and block pens */
CLOSEWINDOW, /* IDCMP flags */
WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | ACTIVATE, /* window flags */
NULL, /* first gadget */
NULL, /* custom screen */
"My Amiga Window", /* window title */
NULL, /* custom bitmap */
NULL, /* minimum width */
NULL, /* minimum height */
NULL, /* maximum width */
NULL /* maximum height */
};
int main(void)
{
/* Open intuition library */
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
if (IntuitionBase == NULL) return 1;
/* Open our window */
MyWindow = OpenWindow(&NewWindowStructure);
if (MyWindow == NULL) {
CloseLibrary((struct Library *)IntuitionBase);
return 1;
}
/* Wait for close gadget to be clicked */
BOOL done = FALSE;
while (!done) {
struct IntuiMessage *message;
Wait(1 << MyWindow->UserPort->mp_SigBit);
while ((message = (struct IntuiMessage *)GetMsg(MyWindow->UserPort))) {
if (message->Class == CLOSEWINDOW) done = TRUE;
ReplyMsg((struct Message *)message);
}
}
/* Clean up */
CloseWindow(MyWindow);
CloseLibrary((struct Library *)IntuitionBase);
return 0;
}
This program:
- Opens the Intuition library (Amiga's GUI system)
- Creates a simple window with a title bar, close gadget, and depth gadget
- Waits for the user to click the close gadget
- Cleans up and exits
To compile this on an Amiga system, you would typically use SAS/C or DICE C compiler. The program creates a basic 300x100 pixel window that can be dragged around the screen and closed.
I can provide more complex examples or explain any part of the code in more detail if you're interested.