2024-04-15 19:29:51 +00:00
|
|
|
#include "ctrl.h"
|
2024-04-30 21:41:31 +00:00
|
|
|
|
2024-04-03 23:31:47 +00:00
|
|
|
#include "event.h"
|
2024-04-30 21:41:31 +00:00
|
|
|
#include "fumocommon.h"
|
|
|
|
|
2024-03-25 05:34:59 +00:00
|
|
|
|
2024-04-19 20:23:11 +00:00
|
|
|
void ErrorExit(char *message)
|
|
|
|
{
|
|
|
|
printf(message);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2024-04-30 21:41:31 +00:00
|
|
|
struct FumoGame {
|
|
|
|
struct Controller ctrl;
|
|
|
|
struct InputHandle input_hand;
|
|
|
|
|
|
|
|
struct Event start;
|
|
|
|
struct Event draw;
|
|
|
|
struct Event update;
|
2024-04-22 22:13:13 +00:00
|
|
|
|
|
|
|
Time time;
|
|
|
|
};
|
|
|
|
|
2024-04-30 21:41:31 +00:00
|
|
|
bool FumoEngineInit(struct FumoGame *game)
|
2024-04-09 07:00:48 +00:00
|
|
|
{
|
2024-04-19 20:23:11 +00:00
|
|
|
if (!PlatformInit())
|
|
|
|
ErrorExit("Platform failed to initialize");
|
|
|
|
|
2024-04-30 21:41:31 +00:00
|
|
|
if (!CreateCtrl(&game->ctrl))
|
2024-04-19 20:23:11 +00:00
|
|
|
ErrorExit("Out of memory");
|
2024-04-03 23:31:47 +00:00
|
|
|
|
2024-04-30 21:41:31 +00:00
|
|
|
//CtrlMap(&ctrl, 0, BUTTON, 'A');
|
2024-04-29 20:01:48 +00:00
|
|
|
|
2024-04-30 21:41:31 +00:00
|
|
|
CreateEvent(&game->update);
|
2024-04-22 22:13:13 +00:00
|
|
|
|
2024-04-30 21:41:31 +00:00
|
|
|
if (!BeginInputThread(&game->input_hand, &game->input_hand.recs, &ctrl.str))
|
2024-04-19 20:23:11 +00:00
|
|
|
ErrorExit("Input handle failed to initialize");
|
2024-04-03 23:31:47 +00:00
|
|
|
|
2024-04-22 05:19:54 +00:00
|
|
|
while (true) {
|
2024-04-29 20:01:48 +00:00
|
|
|
if (!InputAquire(&input_hand))
|
|
|
|
ErrorExit("Aquire failed");
|
|
|
|
|
2024-04-30 04:43:41 +00:00
|
|
|
CtrlPoll(&ctrl);
|
|
|
|
|
2024-04-29 20:01:48 +00:00
|
|
|
if (!InputRelease(&input_hand))
|
|
|
|
ErrorExit("Release failed");
|
2024-04-22 05:19:54 +00:00
|
|
|
|
2024-04-30 21:41:31 +00:00
|
|
|
EventInvokeUpdate(&game.update, 0);
|
2024-04-22 05:19:54 +00:00
|
|
|
}
|
2024-04-03 23:31:47 +00:00
|
|
|
|
2024-03-25 05:34:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|