From 1598091e0c5bb36bc036ffa2219e675f1a2976cd Mon Sep 17 00:00:00 2001 From: tixiv Date: Fri, 5 Dec 2008 02:10:34 +0000 Subject: [PATCH] can run simple animations in simulator. random support for simulator still needs work. --- Makefile | 2 +- simulator/Makefile | 2 +- simulator/joystick.c | 6 ++++++ simulator/joystick.h | 15 +++++++++++++++ simulator/util.c | 26 ++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 simulator/joystick.c create mode 100644 simulator/joystick.h create mode 100644 simulator/util.c diff --git a/Makefile b/Makefile index 9d89982..983f460 100644 --- a/Makefile +++ b/Makefile @@ -120,7 +120,7 @@ SUBDIROBJECTS_SIM = $(foreach subdir,$(SUBDIRS_SIM),$(foreach object,$(shell cat OBJECTS_SIM = $(patsubst %.c,obj_sim/%.o,${SRC_SIM}) $(TARGET_SIM): $(OBJECTS_SIM) $(SUBDIROBJECTS_SIM) - $(HOSTCC) $(LDFLAGS_SIM) $(LIBS_SIM) -o $@ $(SUBDIROBJECTS_SIM) + $(HOSTCC) $(LDFLAGS_SIM) -o $@ $(OBJECTS_SIM) $(SUBDIROBJECTS_SIM) $(LIBS_SIM) ./obj_sim/%.o: %.c @ if [ ! -d obj_sim ]; then mkdir obj_sim ; fi diff --git a/simulator/Makefile b/simulator/Makefile index 45245f4..8189708 100644 --- a/simulator/Makefile +++ b/simulator/Makefile @@ -3,7 +3,7 @@ TOPDIR = .. include $(TOPDIR)/defaults.mk -SRC_SIM = main.c trackball.c +SRC_SIM = main.c trackball.c util.c include $(TOPDIR)/rules.mk diff --git a/simulator/joystick.c b/simulator/joystick.c new file mode 100644 index 0000000..86d8d9c --- /dev/null +++ b/simulator/joystick.c @@ -0,0 +1,6 @@ +#include "joystick.h" + +// fake function since our keybord doesn't need any initialisation +void joy_init() +{ +} diff --git a/simulator/joystick.h b/simulator/joystick.h new file mode 100644 index 0000000..707ba4b --- /dev/null +++ b/simulator/joystick.h @@ -0,0 +1,15 @@ +#ifndef JOYSTICK_H_ +#define JOYSTICK_H_ + +unsigned char fakeport; + +#define JOYISFIRE (0x01 & fakeport) +#define JOYISLEFT (0x02 & fakeport) +#define JOYISRIGHT (0x04 & fakeport) +#define JOYISDOWN (0x08 & fakeport) +#define JOYISUP (0x10 & fakeport) + +unsigned char waitForFire; + + +#endif /*JOYSTICK_H_*/ diff --git a/simulator/util.c b/simulator/util.c new file mode 100644 index 0000000..97d59cf --- /dev/null +++ b/simulator/util.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include +#include "joystick.h" + +#ifdef _WIN32 +# include +#endif + +extern jmp_buf newmode_jmpbuf; + +void wait(unsigned int ms) { + if (waitForFire) { + if (JOYISFIRE) { + longjmp(newmode_jmpbuf, 43); + } + } + +#ifdef _WIN32 + Sleep(ms); +#else + usleep(ms*1000); +#endif +}