Files
amipathy/amiga/main.c
2026-06-28 11:37:58 -05:00

77 lines
2.0 KiB
C

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <devices/input.h>
#include <devices/inputevent.h>
#include <intuition/screens.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <proto/dos.h>
#include <dos/dos.h>
#include "../deps/nanocobs/cobs.h"
#include "../packet.h"
struct IntuitionBase* Intuit;
struct packet ReadPacket() {
struct packet p;
// todo
return p;
}
int main() {
printf("Amipathy Server v1\n"
"by bonkmaykr/madarao\n"
);
struct IOStdReq* InputIO;
struct MsgPort* InputMP;
struct InputEvent* FakeEvent;
struct IEPointerPixel* NeoPix;
struct Screen* PubScreen;
// ReSharper disable CppUsingResultOfAssignmentAsCondition
if ((InputMP = CreateMsgPort())
&& (FakeEvent = AllocMem(sizeof(struct InputEvent),MEMF_PUBLIC))
&& (NeoPix = AllocMem(sizeof(struct IEPointerPixel),MEMF_PUBLIC))
&& (InputIO = CreateIORequest(InputMP,sizeof(struct IOStdReq)))
&& (!OpenDevice("input.device",NULL, (struct IORequest*)InputIO,NULL))
&& (Intuit = (struct IntuitionBase*)OpenLibrary("intuition.library",36L))) {
while (true) {
PubScreen = (struct Screen*)LockPubScreen(NULL);
if (!PubScreen) goto stall;
struct packet p = ReadPacket();
NeoPix->iepp_Screen = PubScreen;
NeoPix->iepp_Position.X = p.x;
NeoPix->iepp_Position.Y = p.y;
FakeEvent->ie_EventAddress = (APTR)NeoPix;
FakeEvent->ie_NextEvent = NULL;
FakeEvent->ie_Class = IECLASS_NEWPOINTERPOS;
FakeEvent->ie_SubClass = IESUBCLASS_PIXEL;
FakeEvent->ie_Code = IECODE_NOBUTTON;
FakeEvent->ie_Qualifier = NULL;
InputIO->io_Data = (APTR)FakeEvent;
InputIO->io_Length = sizeof(struct InputEvent);
InputIO->io_Command = IND_WRITEEVENT;
DoIO((struct IORequest *)InputIO);
UnlockPubScreen(NULL, PubScreen);
PubScreen = NULL;
stall:
Delay(1);
}
} else {
printf("init failed\n"
"%p\n%p\n%p\n%p\n%p\n",
InputIO, InputMP, FakeEvent, NeoPix, Intuit
);
abort();
}
}