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

This commit is contained in:
tixiv 2008-12-05 02:10:34 +00:00
parent a7b074a889
commit 1598091e0c
5 changed files with 49 additions and 2 deletions

View File

@ -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

View File

@ -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 Normal file
View File

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

15
simulator/joystick.h Normal file
View File

@ -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 Normal file
View File

@ -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
}