M: write a short C program that opens a GEM AES window on an atari st, does a small GEM VDI drawing inside, maintains its movements and closes it
O: Here's an example C program that opens a GEM AES window on an Atari ST, does a small GEM VDI drawing inside, maintains its movements, and closes it:
Code: Select all
#include <aes.h>
#include <vdi.h>
int main(int argc, char *argv[]) {
int handle;
int x, y;
int movx, movy;
int button;
/* Open a new AES window */
handle = wind_create(NAME | MOVER | CLOSER, 0, 0, 0, 0);
wind_open(handle, 50, 50, 300, 200);
wind_set(handle, WF_NAME, "My GEM AES Window", 0, 0);
/* Open a new VDI workstation */
handle = graf_handle(&x, &y, &w, &h);
v_opnvwk(work_in, &handle, work_out);
v_clrwk(handle);
/* Draw a small rectangle */
v_bar(handle, 10, 10, 20, 20);
/* Wait for the user to move or close the window */
do {
evnt_mesag(msg_buf);
switch (msg_buf[0]) {
case WM_MOVED:
wind_get(handle, WF_CURRXYWH, &movx, &movy, &w, &h);
break;
case WM_CLOSED:
break;
case WM_MOUSE:
if (msg_buf[4] == 1) {
button = msg_buf[3];
}
break;
}
} while (msg_buf[0] != WM_CLOSED);
/* Close the VDI workstation */
v_clsvwk(handle);
/* Exit the program */
return 0;
}
Although not entirely correct (it clears the screen instead of the window contents only), this appears to be a valid GEM program.
I find this pretty impressive (considering the fact that the amount of information available on the internet about GEM programming still seems to be enough to train a neuronal net to write nearly bug-free code. It appears OpenAI is using a Pure-C compiler?