Browse Source

can run simple animations in simulator. random support for simulator still needs work.

feature/2015
tixiv 16 years ago
parent
commit
1598091e0c
  1. 2
      Makefile
  2. 2
      simulator/Makefile
  3. 6
      simulator/joystick.c
  4. 15
      simulator/joystick.h
  5. 26
      simulator/util.c

2
Makefile

@ -120,7 +120,7 @@ SUBDIROBJECTS_SIM = $(foreach subdir,$(SUBDIRS_SIM),$(foreach object,$(shell cat
OBJECTS_SIM = $(patsubst %.c,obj_sim/%.o,${SRC_SIM}) OBJECTS_SIM = $(patsubst %.c,obj_sim/%.o,${SRC_SIM})
$(TARGET_SIM): $(OBJECTS_SIM) $(SUBDIROBJECTS_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 ./obj_sim/%.o: %.c
@ if [ ! -d obj_sim ]; then mkdir obj_sim ; fi @ if [ ! -d obj_sim ]; then mkdir obj_sim ; fi

2
simulator/Makefile

@ -3,7 +3,7 @@ TOPDIR = ..
include $(TOPDIR)/defaults.mk include $(TOPDIR)/defaults.mk
SRC_SIM = main.c trackball.c SRC_SIM = main.c trackball.c util.c
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk

6
simulator/joystick.c

@ -0,0 +1,6 @@
#include "joystick.h"
// fake function since our keybord doesn't need any initialisation
void joy_init()
{
}

15
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_*/

26
simulator/util.c

@ -0,0 +1,26 @@
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <setjmp.h>
#include "joystick.h"
#ifdef _WIN32
# include <windows.h>
#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
}
Loading…
Cancel
Save