diff --git a/.gitignore b/.gitignore index 7caf0f6..be6dfd2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,27 +7,12 @@ .settings .simulated_eeprom.bin .subdirs -animations/bitmapscroller/obj_avr -animations/bitmapscroller/obj_sim -animations/obj_avr -animations/obj_sim -autoconf.h -borg_hw/obj_avr borgsim borgsim.exe -can/obj_avr -can/obj_sim config.mk -games/breakout/obj_avr -games/breakout/obj_sim -games/snake/obj_avr -games/snake/obj_sim -games/space_invaders/obj_avr -games/space_invaders/obj_sim -games/tetris/obj_avr -games/tetris/obj_sim +doc/html +doc/latex gmon.out -html image image.bin image.elf @@ -38,23 +23,38 @@ image.srec image_eeprom.bin image_eeprom.hex image_eeprom.srec -joystick/obj_avr -joystick/obj_sim -latex -menu/obj_avr -menu/obj_sim obj_avr obj_sim -random/obj_avr -random/obj_sim -rfm12/obj_avr -rfm12/obj_sim +scripts/lxdialog/*.o scripts/lxdialog/a.exe scripts/lxdialog/lxdialog scripts/lxdialog/lxdialog.exe -scripts/lxdialog/*.o -scrolltext/obj_avr -scrolltext/obj_sim -simulator/obj_sim -smallani/obj_avr -smallani/obj_sim +src/animations/bitmapscroller/obj_avr +src/animations/bitmapscroller/obj_sim +src/animations/obj_avr +src/animations/obj_sim +src/autoconf.h +src/borg_hw/obj_avr +src/can/obj_avr +src/can/obj_sim +src/games/breakout/obj_avr +src/games/breakout/obj_sim +src/games/snake/obj_avr +src/games/snake/obj_sim +src/games/space_invaders/obj_avr +src/games/space_invaders/obj_sim +src/games/tetris/obj_avr +src/games/tetris/obj_sim +src/joystick/obj_avr +src/joystick/obj_sim +src/menu/obj_avr +src/menu/obj_sim +src/random/obj_avr +src/random/obj_sim +src/rfm12/obj_avr +src/rfm12/obj_sim +src/scrolltext/obj_avr +src/scrolltext/obj_sim +src/simulator/obj_sim +src/smallani/obj_avr +src/smallani/obj_sim diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5f59921 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/rfm12/rfm12_lib"] + path = src/rfm12/rfm12_lib + url = https://github.com/das-labor/librfm12.git diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e145e74 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: c + +# install dependencies +before_install: + - uname -a + - lsb_release -a + +install: + - sudo apt-get install -qq libncurses5-dev gcc-avr avr-libc + +# run tests +script: + - make test diff --git a/COMPILING.txt b/COMPILING.txt deleted file mode 100644 index 5a2b7ad..0000000 --- a/COMPILING.txt +++ /dev/null @@ -1,27 +0,0 @@ - -**** Ubuntu Linux ***** -To Compile for the AVR you'll need the packages gcc-avr and avr-libc. You'll -also need gcc and libncurses to be able to use menuconfig. To use the simulator -you'll also need libglut. - -Type -$ make menuconfig -and set your settings or load one of the default profiles. Then type -$ make -to compile for the avr. You can upload the image to a borg-16's serial -bootloader (foodloader) by typing -$ make sflash -. - - -****Windows XP**** -Under Windows you'll need to install the following things: --WinAVR --Cygwin with the following packages: ---gcc ---libncurses-devel ---make (the one that WinAVR delivers doesn't work right) ---opengl (for the simulator) - -now go to the cygwin bash shell and use the same commands as with Linux to -compile and flash. diff --git a/Doxyfile b/Doxyfile index c69f0c9..bd03276 100644 --- a/Doxyfile +++ b/Doxyfile @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = +OUTPUT_DIRECTORY = doc # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -647,7 +647,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = +INPUT = src # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/Makefile b/Makefile index 0f49cff..22e8b5c 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,18 @@ TARGET := image TARGET_SIM := borgsim -TOPDIR = . +TOPDIR = src +MAKETOPDIR = . SRC = \ - main.c \ - display_loop.c \ - eeprom_reserve.c \ - pixel.c \ - util.c \ + $(TOPDIR)/main.c \ + $(TOPDIR)/display_loop.c \ + $(TOPDIR)/eeprom_reserve.c \ + $(TOPDIR)/pixel.c \ + $(TOPDIR)/util.c \ SRC_SIM = \ - display_loop.c \ - pixel.c \ + $(TOPDIR)/display_loop.c \ + $(TOPDIR)/pixel.c \ LAUNCH_BOOTLOADER = launch-bootloader @@ -24,26 +25,26 @@ all: compile-$(TARGET) @echo "===============================" @echo "$(TARGET) compiled for: $(MCU)" @echo "size is: " - @$(CONFIG_SHELL) ${TOPDIR}/scripts/size $(TARGET) + @$(CONFIG_SHELL) scripts/size $(TARGET) @echo "===============================" ############################################################################## # generic fluff -include defaults.mk -#include $(TOPDIR)/rules.mk +include $(MAKETOPDIR)/defaults.mk +#include $(MAKETOPDIR)/rules.mk ############################################################################## # generate SUBDIRS variable # -.subdirs: autoconf.h +.subdirs: $(TOPDIR)/autoconf.h @ echo "checking in which subdirs to build" @ $(RM) -f $@ - @ echo "SUBDIRS += animations" >> $@ - @ echo "SUBDIRS += animations/bitmapscroller" >> $@ - @ echo "SUBDIRS += smallani" >> $@ - @ (for subdir in `grep -e "^#define .*_SUPPORT" autoconf.h \ - | sed -e "s/^#define //" -e "s/_SUPPORT.*//" \ + @ echo "SUBDIRS += $(TOPDIR)/animations" >> $@ + @ echo "SUBDIRS += $(TOPDIR)/animations/bitmapscroller" >> $@ + @ echo "SUBDIRS += $(TOPDIR)/smallani" >> $@ + @ (for subdir in `grep -e "^#define .*_SUPPORT" $(TOPDIR)/autoconf.h \ + | sed -e "s/^#define /$(TOPDIR)\//" -e "s/_SUPPORT.*//" \ | tr "[A-Z]\\n" "[a-z] " `; do \ test -d $$subdir && echo "SUBDIRS += $$subdir" ; \ done) | sort -u >> $@ @@ -53,8 +54,8 @@ ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),mrproper) ifneq ($(MAKECMDGOALS),menuconfig) -include $(TOPDIR)/.subdirs -include $(TOPDIR)/.config +-include $(MAKETOPDIR)/.subdirs +include $(MAKETOPDIR)/.config include $(TOPDIR)/games/games.mk endif # MAKECMDGOALS!=menuconfig @@ -65,7 +66,7 @@ endif # no_deps!=t ############################################################################## -SUBDIRS_AVR = borg_hw +SUBDIRS_AVR = $(TOPDIR)/borg_hw SUBDIRS_AVR += $(SUBDIRS) .PHONY: compile-subdirs_avr @@ -77,7 +78,7 @@ compile-$(TARGET): compile-subdirs_avr $(TARGET).hex $(TARGET).bin $(TARGET).lst -OBJECTS += $(patsubst %.c,./obj_avr/%.o,${SRC}) +OBJECTS += $(patsubst $(TOPDIR)/%.c,$(TOPDIR)/obj_avr/%.o,${SRC}) SUBDIROBJECTS = $(foreach subdir,$(SUBDIRS_AVR),$(foreach object,$(shell cat $(subdir)/obj_avr/.objects 2>/dev/null),$(subdir)/$(object))) $(TARGET): $(OBJECTS) $(SUBDIROBJECTS) @@ -86,8 +87,8 @@ $(TARGET): $(OBJECTS) $(SUBDIROBJECTS) ############################################################################## #generic rules for AVR-Build -./obj_avr/%.o: %.c - @ if [ ! -d obj_avr ]; then mkdir obj_avr ; fi +$(TOPDIR)/obj_avr/%.o: $(TOPDIR)/%.c + @ if [ ! -d $(TOPDIR)/obj_avr ]; then mkdir $(TOPDIR)/obj_avr ; fi @ echo "compiling $<" @ $(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c $< @@ -109,25 +110,25 @@ $(TARGET): $(OBJECTS) $(SUBDIROBJECTS) ############################################################################## #Rules for simulator build -SUBDIRS_SIM = simulator +SUBDIRS_SIM = $(TOPDIR)/simulator SUBDIRS_SIM += $(SUBDIRS) .PHONY: compile-subdirs_sim compile-subdirs_sim: @ for dir in $(SUBDIRS_SIM); do $(MAKE) -C $$dir objects_sim || exit 5; done - @ $(MAKE) -C ./simulator/ objects_sim || exit 5; + @ $(MAKE) -C $(TOPDIR)/simulator/ objects_sim || exit 5; -simulator: autoconf.h .config .subdirs compile-subdirs_sim $(TARGET_SIM) +simulator: $(TOPDIR)/autoconf.h .config .subdirs compile-subdirs_sim $(TARGET_SIM) SUBDIROBJECTS_SIM = $(foreach subdir,$(SUBDIRS_SIM),$(foreach object,$(shell cat $(subdir)/obj_sim/.objects 2>/dev/null),$(subdir)/$(object))) -OBJECTS_SIM = $(patsubst %.c,obj_sim/%.o,${SRC_SIM}) +OBJECTS_SIM = $(patsubst $(TOPDIR)/%.c,$(TOPDIR)/obj_sim/%.o,${SRC_SIM}) $(TARGET_SIM): $(OBJECTS_SIM) $(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 +$(TOPDIR)/obj_sim/%.o: $(TOPDIR)/%.c + @ if [ ! -d $(TOPDIR)/obj_sim ]; then mkdir $(TOPDIR)/obj_sim ; fi @ echo "compiling $<" @ $(HOSTCC) -o $@ $(CFLAGS_SIM) -c $< @@ -145,6 +146,21 @@ menuconfig: @echo "Next, you can: " @echo " * 'make' to compile your borgware" +test: + @echo $(CONFIG_SHELL) + @echo + @echo "========== Testing borg-16 ========== " + $(MAKE) -C scripts/lxdialog all + $(CONFIG_SHELL) scripts/Menuconfig config.in profiles/borg-16 + $(MAKE) + $(MAKE) clean + @echo + @echo "========== Testing borg-ls ========== " + $(MAKE) -C scripts/lxdialog all + $(CONFIG_SHELL) scripts/Menuconfig config.in profiles/borg-ls + $(MAKE) + $(MAKE) clean + #%/menuconfig: # $(SH) "$(@D)/configure" # @$(MAKE) what-now-msg @@ -152,44 +168,48 @@ menuconfig: ############################################################################## clean: $(MAKE) -f rules.mk no_deps=t clean-common - $(RM) $(TARGET) $(TARGET).bin $(TARGET).hex $(TARGET).lst .subdirs - for subdir in `find . -type d` ; do \ + $(RM) -f $(TARGET) $(TARGET).bin $(TARGET).hex $(TARGET).lst .subdirs + $(RM) -f $(TARGET).map + for subdir in `find . -type d ! -iwholename './src/rfm12/rfm12_lib/examples/*'` ; do \ test "x$$subdir" != "x." \ && test -e $$subdir/Makefile \ && $(MAKE) no_deps=t -C $$subdir clean ; done ; true + $(RM) -fr $(TOPDIR)/obj_avr $(TOPDIR)/obj_sim + $(RM) -f $(TARGET_SIM) $(TARGET_SIM).exe mrproper: $(MAKE) clean - $(RM) -f autoconf.h .config config.mk .menuconfig.log .config.old + $(RM) -f $(TOPDIR)/autoconf.h .config config.mk .menuconfig.log .config.old -sflash: $(TARGET).hex +#sflash: $(TARGET).hex # $(LAUNCH_BOOTLOADER) $(SERIAL) 115200 - avrdude -p m32 -b 115200 -u -c avr109 -P $(SERIAL) -U f:w:$< -F - echo X > $(SERIAL) +# avrdude -p m32 -b 115200 -u -c avr109 -P $(SERIAL) -U f:w:$< -F +# echo X > $(SERIAL) -uflash: $(TARGET).hex - avrdude -c usbasp -p atmega32 -V -U f:w:$< -F +#uflash: $(TARGET).hex +# avrdude -c usbasp -p atmega32 -V -U f:w:$< -F .PHONY: clean mrproper sflash uflash ############################################################################## # configure ethersex # -show-config: autoconf.h +show-config: $(TOPDIR)/autoconf.h @echo @echo "These modules are currently enabled: " @echo "======================================" - @grep -e "^#define .*_SUPPORT" autoconf.h | sed -e "s/^#define / * /" -e "s/_SUPPORT.*//" + @grep -e "^#define .*_SUPPORT" $(TOPDIR)/autoconf.h | sed -e "s/^#define / * /" -e "s/_SUPPORT.*//" .PHONY: show-config -autoconf.h .config: +$(TOPDIR)/autoconf.h .config: @echo make\'s goal: $(MAKECMDGOALS) ifneq ($(MAKECMDGOALS),menuconfig) # make sure menuconfig isn't called twice, on `make menuconfig' - test -s autoconf.h -a -s .config || $(MAKE) no_deps=t menuconfig + #test -s $(TOPDIR)/autoconf.h -a -s .config || $(MAKE) no_deps=t menuconfig # test the target file, test fails if it doesn't exist # and will keep make from looping menuconfig. - test -s autoconf.h -a -s .config + #test -s $(TOPDIR)/autoconf.h -a -s .config + touch $(TOPDIR)/autoconf.h .config endif -include depend.mk +include $(MAKETOPDIR)/depend.mk diff --git a/Makefile-old b/Makefile-old deleted file mode 100644 index 8f39dd6..0000000 --- a/Makefile-old +++ /dev/null @@ -1,32 +0,0 @@ - -OBJ = borg_hw.o main.o util.o pixel.o program.o borg_can.o can.o \ - spi.o scrolltext3.o font_arial8.o joystick.o snake.o \ - eeprom_reserve.o persistentCounter.o prng.o matrix.o \ - invader_draw.o invader_init.o invader_proc.o invaders2.o \ - tetris/tetris.o menu.o gameoflife.o memxor.o noekeon_asm.o \ - mcuf.o uart.o - -CANADDR = 0x43 - -SERIAL = /dev/ttyUSB0 - -include ../../make/avr.mk - -.PHONY: tetris/tetris.o -tetris/tetris.o: - $(MAKE) "MCU_CC=$(MCU_CC)" "MCU_LD=$(MCU_LD)" "LDFLAGS=$(LDFLAGS)" \ - "CFLAGS=$(CFLAGS) -DNDEBUG -pedantic -std=c99" --directory=tetris - -LAUNCH_BOOTLOADER = launch-bootloader - -sflash: $(OUT).hex - $(LAUNCH_BOOTLOADER) $(SERIAL) 115200 - avrdude -p m32 -b 115200 -u -c avr109 -P $(SERIAL) -U f:w:$(OUT).hex -F - echo X > $(SERIAL) - -urflash: image_with_bootloader.hex - avrdude -p m32 -c bsd -P /dev/parport0 -U hfuse:w:0xdc:m - avrdude -p m32 -c bsd -P /dev/parport0 -U lfuse:w:0xef:m - avrdude -p m32 -c bsd -P /dev/parport0 -U f:w:image_with_bootloader.hex - avrdude -p m32 -c bsd -P /dev/parport0 -U e:w:image_eeprom.hex - avrdude -p m32 -c bsd -P /dev/parport0 -U lock:w:0x2f:m diff --git a/README.md b/README.md new file mode 100644 index 0000000..35f3d6f --- /dev/null +++ b/README.md @@ -0,0 +1,122 @@ +Borgware-2D +=========== + +Firmware for AVR based two-dimensional LED matrices, especially the +[Blinken Borgs](http://www.das-labor.org/wiki/Blinken_Borgs) from +[Das LABOR](http://das-labor.org/index.en.php). +Main platform is the [Borg16](http://www.das-labor.org/wiki/Borg16) construction +kit. Other supported platforms are the +[LED Brett](http://www.hackerspace-ffm.de/wiki/index.php?title=LedBrett) +projector from [Hackerspace FFM](http://www.hackerspace-ffm.de) or the +[ELO Ping-Pong Board](http://www.elo-web.de/elo/mikrocontroller-und-programmierung/ping-pong/das-franzis-pingpong). + +![Small Borg16](/doc/img/Borg16-small.jpg) +![Glow Lamp Borg](/doc/img/Glow_Lamp_Borg.jpg) + +Animations +---------- + +![Matrix](/doc/img/anim-matrix.png) +![Fire](/doc/img/anim-feuer.png) +![Scrolling Text](/doc/img/anim-scroll.png) + +[Animated GIF (3.5 MB)](/doc/img/borg_anim.gif) + +Games +----- + +![Snake](/doc/img/game-snake.png) +![Tetris](/doc/img/game-tetris.png) + +* Tetris + * Classic: Standard Tetris Clone + * First Person Tetris: Rotate the bucket instead of the Tetromino. + * Bastet: Dices the worst the possible Tetromino the whole time. +* Snake +* Breakout +* Space Invaders + +Build +===== + +Supported build platforms are Linux, FreeBSD and Windows (via Cygwin). Due to +customized linker scripts, simulator support is currently limited to x86 and +x86_64 archs. Following dependencies have to be met: + +Linux / FreeBSD +--------------- + +Package names are based on Debian/Ubuntu repositories. Please adapt the names +according to your Linux distribution (or FreeBSD for that matter). + +* build-essential (pulls in an ordinary gcc build tool chain for the host) +* bc +* make (gmake on FreeBSD) +* libncurses5-dev +* gcc-avr +* avr-libc +* binutils-avr +* avrdude +* freeglut3-dev + +Windows +------- +* AVR GCC toolchain for Windows, choose your poison: + * [WinAVR](http://winavr.sourceforge.net) + * already includes [avrdude](http://www.nongnu.org/avrdude/) + * installer offers to add the toolchain to the system path + * straight forward download from SourceForge + * project abandoned in 2010, therefore heavily outdated (avr-gcc 4.3.3) + * [Atmel AVR Toolchain for Windows](http://www.atmel.com/tools/atmelavrtoolchainforwindows.aspx) + * actively maintained, therefore fairly up to date + * homepage nags you with rather awkward registration process before download + * you have to add the toolchain to the system path manually + * avrdude is not included (but it is possible to install WinAVR in parallel) +* [Cygwin(64)](http://www.cygwin.com/) + * bc + * make + * gcc-core + * gdb (in case you want to debug your code in the simulator) + * libncurses-devel (Cygwin) + * libncursesw-devel (Cygwin64) +* [libusb-win32](http://sourceforge.net/apps/trac/libusb-win32/wiki) in case you + want to use an USBasp programmer device with avrdude + +Configure +--------- + +Open a (Cygwin) terminal, change to your checkout directory and type: + > make menuconfig + +This starts a curses based text interface for configuring certain aspects of +your target platform. Be careful if you use an IDE like Eclipse to manage the +build, as integrated terminal emulators tend to choke on curses generated shell +output. Make sure that 'make menuconfig' has been run at least once in an +ordinary terminal emulator after a fresh checkout or after issuing 'make +mrproper'. + +Compile +------- + +To build for the actual target platform, just type: + > make + +If you want to test and debug your code within a GUI application, you can use +the simulator: + > make simulator + +In case you build on FreeBSD, just use 'gmake' instead of 'make'. + +You can start the simulator by typing ./borgsim(.exe) + +Simulator Handling +------------------ + +Please keep in mind that the simulator is NOT an emulator. All it does is +compile the source code to a native host application so you can step through +your C-Code. The GUI thread reads the simulated frame buffer every 40ms and +draws its contents. + +Joystick directions are simulated by the WASD keys and SPACE acts as the fire +button. The OpenGL based simulator (Linux/FreeBSD) enables you to adjust the +viewing angle of the LED matrix via the arrow keys (not available on Windows). diff --git a/README.txt b/README.txt deleted file mode 100644 index 1f373e3..0000000 --- a/README.txt +++ /dev/null @@ -1,7 +0,0 @@ - -Hier liegt der Versuch, eine universelle Codebasis für 2d-borgs zu bauen, die -durch 'make menuconfig' konfigurierbar ist. -Zur Zeit ist es bereits möglich, gewisse Dinge in menuconfig einzustellen. -Einfach mal ansehen! Compiliert werden kann das Ganze auch schon. -Außerdem wird grade versucht, das Ganze mit dem Borg-api-Simulator zu -integrieren. \ No newline at end of file diff --git a/can/Makefile b/can/Makefile deleted file mode 100644 index bc1001a..0000000 --- a/can/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -TARGET = libcan.a -TOPDIR = .. - -include $(TOPDIR)/defaults.mk - -ifeq ($(CAN_SUPPORT),y) - SRC = can.c - SRC += borg_can.c - SRC += lap.c - SRC += spi.c -endif - -include $(TOPDIR)/rules.mk diff --git a/config.in b/config.in index 35ba82f..57cb324 100644 --- a/config.in +++ b/config.in @@ -11,6 +11,8 @@ comment "General Setup" ATmega328 atmega328 \ ATmega644 atmega644 \ ATmega644p atmega644p \ + ATmega1284 atmega1284 \ + ATmega1284p atmega1284p \ ATmega8515 atmega8515" \ 'ATmega32' MCU @@ -20,7 +22,7 @@ endmenu ### Borg Hardware Menu ######################################################## -source borg_hw/config.in +source src/borg_hw/config.in ############################################################################### @@ -34,22 +36,22 @@ endmenu ### Scrolltext Menu ########################################################### -source scrolltext/config.in +source src/scrolltext/config.in ############################################################################### ### RFM12 Menu ################################################################ -source rfm12/config.in +source src/rfm12/config.in ############################################################################### ### Joystick Menu ############################################################# -source joystick/config.in +source src/joystick/config.in ############################################################################### ### CAN Menu ################################################################## -source can/config.in +source src/can/config.in ############################################################################### @@ -60,15 +62,15 @@ depends on JOYSTICK_SUPPORT ### Game Menu ################################################################# -source games/config.in +source src/games/config.in ############################################################################### ### Animations Menu ########################################################### -source animations/config.in +source src/animations/config.in ############################################################################### ### small Animations Menu ##################################################### -source smallani/config.in +source src/smallani/config.in ############################################################################### diff --git a/defaults.mk b/defaults.mk index 13cd0ac..129e2c5 100644 --- a/defaults.mk +++ b/defaults.mk @@ -23,10 +23,6 @@ LIBS = -lm CFLAGS ?= -Wall -W -Wno-unused-parameter -Wno-sign-compare CFLAGS += -g -Os -std=gnu99 -fgnu89-inline -D_XOPEN_SOURCE=600 -DNDEBUG -# flags for the linker -LDFLAGS += -T ./avr5.x -Wl,-Map,image.map -mmcu=$(MCU) - - ############################################################################# #Settings for Simulator build @@ -41,24 +37,29 @@ MACHINE = $(shell uname -m) ifeq ($(findstring CYGWIN,$(OSTYPE)),CYGWIN) CFLAGS_SIM = -g -Wall -pedantic -std=c99 -O0 -D_WIN32 -D_XOPEN_SOURCE=600 - LDFLAGS_SIM = -T simulator/i386pe.x + ifeq ($(MACHINE),x86_64) + LDFLAGS_SIM = -T ld_scripts/i386pep.x + else + LDFLAGS_SIM = -T ld_scripts/i386pe.x + endif LIBS_SIM = -lgdi32 -lwinmm -lm else ifeq ($(OSTYPE),FreeBSD) - CFLAGS_SIM = -g -I/usr/local/include -Wall -pedantic -std=c99 -O0 -D_XOPEN_SOURCE=600 + CFLAGS_SIM = -g -I/usr/local/include -Wall -pedantic -std=c99 -O0 + CFLAGS_SIM += -D_XOPEN_SOURCE=600 ifeq ($(MACHINE),amd64) - LDFLAGS_SIM = -L/usr/local/lib -T simulator/elf_x86_64_fbsd.x + LDFLAGS_SIM = -L/usr/local/lib -T ld_scripts/elf_x86_64_fbsd.x else - LDFLAGS_SIM = -L/usr/local/lib -T simulator/elf_i386_fbsd.x + LDFLAGS_SIM = -L/usr/local/lib -T ld_scripts/elf_i386_fbsd.x endif LIBS_SIM = -lglut -lpthread -lGL -lGLU -lm else ifeq ($(OSTYPE),Linux) CFLAGS_SIM = -g -Wall -pedantic -std=c99 -O0 -D_XOPEN_SOURCE=600 ifeq ($(MACHINE),x86_64) - LDFLAGS_SIM = -g -T simulator/elf_x86_64.x + LDFLAGS_SIM = -T ld_scripts/elf_x86_64.x else - LDFLAGS_SIM = -T simulator/elf_i386.x + LDFLAGS_SIM = -T ld_scripts/elf_i386.x endif LIBS_SIM = -lglut -lpthread -lGL -lGLU -lm else @@ -78,12 +79,17 @@ $(TARGET): ############################################################################## # include user's config.mk file -$(TOPDIR)/config.mk: - @echo "# Put your own config here!" > $@ - @echo "#F_CPU = $(F_CPU)" >> $@ - @echo "#MCU = $(MCU)" >> $@ - @echo "created default config.mk, tune your settings there!" --include $(TOPDIR)/config.mk +$(MAKETOPDIR)/config.mk: + @echo "# Customize your config here!" >$@ + @echo "# Add further CFLAGS by using the += operator, eg." >>$@ + @echo "# CFLAGS += -mstrict-X" >>$@ + @echo "#" >>$@ + @echo "# In case you wonder: -mstrict-X produces smaller code, but" >>$@ + @echo "# is only available on avr-gcc 4.7.0 or higher." >>$@ + @echo "#" >>$@ + @echo "# Other flags you might want to tune: CPPFLAGS, LDFLAGS ..." >>$@ + @echo "Created default config.mk, tune your settings there!" +-include $(MAKETOPDIR)/config.mk ############################################################################## @@ -93,17 +99,24 @@ ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),mrproper) ifneq ($(MAKECMDGOALS),menuconfig) -include $(TOPDIR)/.config +include $(MAKETOPDIR)/.config CPPFLAGS += -DF_CPU=$(FREQ)UL -mmcu=$(MCU) +# flags for the linker, choose appropriate linker script +ifeq ($(findstring atmega128,$(MCU)),atmega128) + LDFLAGS += -T ld_scripts/avr51.x -Wl,-Map,image.map -mmcu=$(MCU) +else + LDFLAGS += -T ld_scripts/avr5.x -Wl,-Map,image.map -mmcu=$(MCU) +endif + endif # MAKECMDGOALS!=menuconfig endif # MAKECMDGOALS!=mrproper endif # MAKECMDGOALS!=clean ifeq ($(BOOTLOADER_SUPPORT),y) -LDFLAGS += -Wl,--section-start=.text=0xE000 -CFLAGS += -mcall-prologues + LDFLAGS += -Wl,--section-start=.text=0xE000 + CFLAGS += -mcall-prologues endif diff --git a/doc/img/Borg16-small.jpg b/doc/img/Borg16-small.jpg new file mode 100644 index 0000000..5aa347d Binary files /dev/null and b/doc/img/Borg16-small.jpg differ diff --git a/doc/img/Glow_Lamp_Borg.jpg b/doc/img/Glow_Lamp_Borg.jpg new file mode 100644 index 0000000..64e5549 Binary files /dev/null and b/doc/img/Glow_Lamp_Borg.jpg differ diff --git a/doc/img/anim-feuer.png b/doc/img/anim-feuer.png new file mode 100644 index 0000000..fccb9dc Binary files /dev/null and b/doc/img/anim-feuer.png differ diff --git a/doc/img/anim-matrix.png b/doc/img/anim-matrix.png new file mode 100644 index 0000000..b35266c Binary files /dev/null and b/doc/img/anim-matrix.png differ diff --git a/doc/img/anim-scroll.png b/doc/img/anim-scroll.png new file mode 100644 index 0000000..517e067 Binary files /dev/null and b/doc/img/anim-scroll.png differ diff --git a/doc/img/borg_anim.gif b/doc/img/borg_anim.gif new file mode 100644 index 0000000..0087e84 Binary files /dev/null and b/doc/img/borg_anim.gif differ diff --git a/doc/img/game-snake.png b/doc/img/game-snake.png new file mode 100644 index 0000000..ae33627 Binary files /dev/null and b/doc/img/game-snake.png differ diff --git a/doc/img/game-tetris.png b/doc/img/game-tetris.png new file mode 100644 index 0000000..246a14e Binary files /dev/null and b/doc/img/game-tetris.png differ diff --git a/games/breakout/Makefile b/games/breakout/Makefile deleted file mode 100644 index c5dae36..0000000 --- a/games/breakout/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -TARGET = -TOPDIR = ../.. - -include $(TOPDIR)/defaults.mk - -ifeq ($(GAME_BREAKOUT),y) - SRC = breakout.c playfield.c rebound.c score.c level.c ball.c messages.c -endif - -include $(TOPDIR)/rules.mk diff --git a/games/kart/Makefile b/games/kart/Makefile deleted file mode 100644 index 33bd659..0000000 --- a/games/kart/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -TARGET = -TOPDIR = ../.. - -include $(TOPDIR)/defaults.mk - -SRC = kart.c - -include $(TOPDIR)/rules.mk diff --git a/games/snake/Makefile b/games/snake/Makefile deleted file mode 100644 index 6419b6d..0000000 --- a/games/snake/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -TARGET = -TOPDIR = ../.. - -include $(TOPDIR)/defaults.mk - -SRC = snake_game.c - -include $(TOPDIR)/rules.mk diff --git a/games/space_invaders/Makefile b/games/space_invaders/Makefile deleted file mode 100644 index cf00935..0000000 --- a/games/space_invaders/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -TARGET = -TOPDIR = ../.. - -include $(TOPDIR)/defaults.mk - -SRC = invader_init.c invader_draw.c invader_proc.c invaders2.c - -include $(TOPDIR)/rules.mk diff --git a/avr5.x b/ld_scripts/avr5.x similarity index 100% rename from avr5.x rename to ld_scripts/avr5.x diff --git a/ld_scripts/avr51.x b/ld_scripts/avr51.x new file mode 100644 index 0000000..a16ad36 --- /dev/null +++ b/ld_scripts/avr51.x @@ -0,0 +1,231 @@ +/* Default linker script, for normal executables */ +OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") +OUTPUT_ARCH(avr:51) +MEMORY +{ + text (rx) : ORIGIN = 0, LENGTH = 128K + data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0 + eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K + fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K + lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K + signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K +} +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.text : + { + *(.rel.text) + *(.rel.text.*) + *(.rel.gnu.linkonce.t*) + } + .rela.text : + { + *(.rela.text) + *(.rela.text.*) + *(.rela.gnu.linkonce.t*) + } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.rodata : + { + *(.rel.rodata) + *(.rel.rodata.*) + *(.rel.gnu.linkonce.r*) + } + .rela.rodata : + { + *(.rela.rodata) + *(.rela.rodata.*) + *(.rela.gnu.linkonce.r*) + } + .rel.data : + { + *(.rel.data) + *(.rel.data.*) + *(.rel.gnu.linkonce.d*) + } + .rela.data : + { + *(.rela.data) + *(.rela.data.*) + *(.rela.gnu.linkonce.d*) + } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + /* Internal text space or external memory. */ + .text : + { + *(.vectors) + KEEP(*(.vectors)) + /* For data that needs to reside in the lower 64k of progmem. */ + *(.progmem.gcc*) + *(.progmem*) + . = ALIGN(2); + __trampolines_start = . ; + /* The jump trampolines for the 16-bit limited relocs will reside here. */ + *(.trampolines) + *(.trampolines*) + __trampolines_end = . ; + /* For future tablejump instruction arrays for 3 byte pc devices. + We don't relax jump/call instructions within these sections. */ + *(.jumptables) + *(.jumptables*) + /* For code that needs to reside in the lower 128k progmem. */ + *(.lowtext) + *(.lowtext*) + __ctors_start = . ; + *(.ctors) + __ctors_end = . ; + __dtors_start = . ; + *(.dtors) + __dtors_end = . ; + KEEP(SORT(*)(.ctors)) + KEEP(SORT(*)(.dtors)) + /* From this point on, we don't bother about wether the insns are + below or above the 16 bits boundary. */ + *(.init0) /* Start here after reset. */ + KEEP (*(.init0)) + *(.init1) + KEEP (*(.init1)) + *(.init2) /* Clear __zero_reg__, set up stack pointer. */ + KEEP (*(.init2)) + *(.init3) + KEEP (*(.init3)) + *(.init4) /* Initialize data and BSS. */ + KEEP (*(.init4)) + *(.init5) + KEEP (*(.init5)) + *(.init6) /* C++ constructors. */ + KEEP (*(.init6)) + *(.init7) + KEEP (*(.init7)) + *(.init8) + KEEP (*(.init8)) + *(.init9) /* Call main(). */ + KEEP (*(.init9)) + *(.text) + . = ALIGN(2); + *(.text.*) + . = ALIGN(2); + *(.fini9) /* _exit() starts here. */ + KEEP (*(.fini9)) + *(.fini8) + KEEP (*(.fini8)) + *(.fini7) + KEEP (*(.fini7)) + *(.fini6) /* C++ destructors. */ + KEEP (*(.fini6)) + *(.fini5) + KEEP (*(.fini5)) + *(.fini4) + KEEP (*(.fini4)) + *(.fini3) + KEEP (*(.fini3)) + *(.fini2) + KEEP (*(.fini2)) + *(.fini1) + KEEP (*(.fini1)) + *(.fini0) /* Infinite loop after program termination. */ + KEEP (*(.fini0)) + _etext = . ; + } > text + .data : AT (ADDR (.text) + SIZEOF (.text)) + { + PROVIDE (__data_start = .) ; + *(.data) + *(.data*) + *(.rodata) /* We need to include .rodata here if gcc is used */ + *(.rodata*) /* with -fdata-sections. */ + *(.gnu.linkonce.d*) + PROVIDE (_game_descriptors_start__ = .) ; + *(.game_descriptors) + PROVIDE (_game_descriptors_end__ = .) ; + . = ALIGN(2); + _edata = . ; + PROVIDE (__data_end = .) ; + } > data + .bss SIZEOF(.data) + ADDR(.data) : + { + PROVIDE (__bss_start = .) ; + *(.bss) + *(.bss*) + *(COMMON) + PROVIDE (__bss_end = .) ; + } > data + __data_load_start = LOADADDR(.data); + __data_load_end = __data_load_start + SIZEOF(.data); + /* Global data not cleared after reset. */ + .noinit SIZEOF(.bss) + ADDR(.bss) : + { + PROVIDE (__noinit_start = .) ; + *(.noinit*) + PROVIDE (__noinit_end = .) ; + _end = . ; + PROVIDE (__heap_start = .) ; + } > data + .eeprom : + { + *(.eeprom*) + __eeprom_end = . ; + } > eeprom + .fuse : + { + KEEP(*(.fuse)) + KEEP(*(.lfuse)) + KEEP(*(.hfuse)) + KEEP(*(.efuse)) + } > fuse + .lock : + { + KEEP(*(.lock*)) + } > lock + .signature : + { + KEEP(*(.signature*)) + } > signature + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } +} diff --git a/simulator/elf_i386.x b/ld_scripts/elf_i386.x similarity index 100% rename from simulator/elf_i386.x rename to ld_scripts/elf_i386.x diff --git a/simulator/elf_i386_fbsd.x b/ld_scripts/elf_i386_fbsd.x similarity index 100% rename from simulator/elf_i386_fbsd.x rename to ld_scripts/elf_i386_fbsd.x diff --git a/simulator/elf_x86_64.x b/ld_scripts/elf_x86_64.x similarity index 100% rename from simulator/elf_x86_64.x rename to ld_scripts/elf_x86_64.x diff --git a/simulator/elf_x86_64_fbsd.x b/ld_scripts/elf_x86_64_fbsd.x similarity index 100% rename from simulator/elf_x86_64_fbsd.x rename to ld_scripts/elf_x86_64_fbsd.x diff --git a/simulator/i386pe.x b/ld_scripts/i386pe.x similarity index 75% rename from simulator/i386pe.x rename to ld_scripts/i386pe.x index 6ea1c29..a066a35 100644 --- a/simulator/i386pe.x +++ b/ld_scripts/i386pe.x @@ -24,6 +24,7 @@ SECTIONS /* ??? Why is .gcc_exc here? */ *(.gcc_exc) PROVIDE (etext = .); + PROVIDE (_etext = .); *(.gcc_except_table) } /* The Cygwin32 library uses a section to avoid copying certain data @@ -40,7 +41,7 @@ SECTIONS *(.jcr) __eeprom_start__ = . ; *(.eeprom) - __game_descriptors_start__ = . ; + __game_descriptors_start__ = . ; *(.game_descriptors) __game_descriptors_end__ = . ; __data_end__ = . ; @@ -120,12 +121,18 @@ SECTIONS *(SORT(.CRT$XT*)) /* Termination */ ___crt_xt_end__ = . ; } + /* Windows TLS expects .tls$AAA to be at the start and .tls$ZZZ to be + at the end of section. This is important because _tls_start MUST + be at the beginning of the section to enable SECREL32 relocations with TLS + data. */ .tls BLOCK(__section_alignment__) : { ___tls_start__ = . ; + *(.tls$AAA) *(.tls) *(.tls$) *(SORT(.tls$*)) + *(.tls$ZZZ) ___tls_end__ = . ; } .endjunk BLOCK(__section_alignment__) : @@ -161,72 +168,140 @@ SECTIONS { *(.debug_aranges) } + .zdebug_aranges BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_aranges) + } .debug_pubnames BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_pubnames) } + .zdebug_pubnames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_pubnames) + } .debug_pubtypes BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_pubtypes) } + .zdebug_pubtypes BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_pubtypes) + } /* DWARF 2. */ .debug_info BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_info .gnu.linkonce.wi.*) } + .zdebug_info BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_info .zdebug.gnu.linkonce.wi.*) + } .debug_abbrev BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_abbrev) } + .zdebug_abbrev BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_abbrev) + } .debug_line BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_line) } + .zdebug_line BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_line) + } .debug_frame BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_frame*) } + .zdebug_frame BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_frame*) + } .debug_str BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_str) } + .zdebug_str BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_str) + } .debug_loc BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_loc) } + .zdebug_loc BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_loc) + } .debug_macinfo BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_macinfo) } + .zdebug_macinfo BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_macinfo) + } /* SGI/MIPS DWARF 2 extensions. */ .debug_weaknames BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_weaknames) } + .zdebug_weaknames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_weaknames) + } .debug_funcnames BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_funcnames) } + .zdebug_funcnames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_funcnames) + } .debug_typenames BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_typenames) } + .zdebug_typenames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_typenames) + } .debug_varnames BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_varnames) } + .zdebug_varnames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_varnames) + } .debug_macro BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_macro) } + .zdebug_macro BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_macro) + } /* DWARF 3. */ .debug_ranges BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_ranges) } + .zdebug_ranges BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_ranges) + } /* DWARF 4. */ .debug_types BLOCK(__section_alignment__) (NOLOAD) : { *(.debug_types .gnu.linkonce.wt.*) } + .zdebug_types BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_types .gnu.linkonce.wt.*) + } } diff --git a/ld_scripts/i386pep.x b/ld_scripts/i386pep.x new file mode 100644 index 0000000..ed6324c --- /dev/null +++ b/ld_scripts/i386pep.x @@ -0,0 +1,316 @@ +/* Default linker script, for normal executables */ +OUTPUT_FORMAT(pei-x86-64) +SEARCH_DIR("/usr/x86_64-pc-cygwin/lib"); SEARCH_DIR("/usr/lib"); SEARCH_DIR("/usr/lib/w32api"); +SECTIONS +{ + /* Make the virtual address and file offset synced if the alignment is + lower than the target page size. */ + . = SIZEOF_HEADERS; + . = ALIGN(__section_alignment__); + .text __image_base__ + ( __section_alignment__ < 0x1000 ? . : __section_alignment__ ) : + { + *(.init) + *(.text) + *(SORT(.text$*)) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.glue_7t) + *(.glue_7) + . = ALIGN(8); + ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1); LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); LONG (0); + ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); LONG (0); + *(.fini) + /* ??? Why is .gcc_exc here? */ + *(.gcc_exc) + PROVIDE (etext = .); + *(.gcc_except_table) + } + /* The Cygwin32 library uses a section to avoid copying certain data + on fork. This used to be named ".data". The linker used + to include this between __data_start__ and __data_end__, but that + breaks building the cygwin32 dll. Instead, we name the section + ".data_cygwin_nocopy" and explicitly include it after __data_end__. */ + .data BLOCK(__section_alignment__) : + { + __data_start__ = . ; + *(.data) + *(.data2) + *(SORT(.data$*)) + *(.jcr) + . = ALIGN(16); + _eeprom_start__ = . ; + __eeprom_start__ = . ; + *(.eeprom) + . = ALIGN(16); + _game_descriptors_start__ = . ; + __game_descriptors_start__ = . ; + *(.game_descriptors) + _game_descriptors_end__ = . ; + __game_descriptors_end__ = . ; + __data_end__ = . ; + *(.data_cygwin_nocopy) + } + .rdata BLOCK(__section_alignment__) : + { + *(.rdata) + *(SORT(.rdata$*)) + __rt_psrelocs_start = .; + *(.rdata_runtime_pseudo_reloc) + __rt_psrelocs_end = .; + } + __rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start; + ___RUNTIME_PSEUDO_RELOC_LIST_END__ = .; + __RUNTIME_PSEUDO_RELOC_LIST_END__ = .; + ___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size; + __RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size; + .eh_frame BLOCK(__section_alignment__) : + { + *(.eh_frame*) + } + .pdata BLOCK(__section_alignment__) : + { + *(.pdata*) + } + .xdata BLOCK(__section_alignment__) : + { + *(.xdata*) + } + .bss BLOCK(__section_alignment__) : + { + __bss_start__ = . ; + *(.bss) + *(COMMON) + __bss_end__ = . ; + } + .edata BLOCK(__section_alignment__) : + { + *(.edata) + } + /DISCARD/ : + { + *(.debug$S) + *(.debug$T) + *(.debug$F) + *(.drectve) + *(.note.GNU-stack) + *(.gnu.lto_*) + } + .idata BLOCK(__section_alignment__) : + { + /* This cannot currently be handled with grouped sections. + See pep.em:sort_sections. */ + SORT(*)(.idata$2) + SORT(*)(.idata$3) + /* These zeroes mark the end of the import list. */ + LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); + SORT(*)(.idata$4) + __IAT_start__ = .; + SORT(*)(.idata$5) + __IAT_end__ = .; + SORT(*)(.idata$6) + SORT(*)(.idata$7) + } + .CRT BLOCK(__section_alignment__) : + { + ___crt_xc_start__ = . ; + *(SORT(.CRT$XC*)) /* C initialization */ + ___crt_xc_end__ = . ; + ___crt_xi_start__ = . ; + *(SORT(.CRT$XI*)) /* C++ initialization */ + ___crt_xi_end__ = . ; + ___crt_xl_start__ = . ; + *(SORT(.CRT$XL*)) /* TLS callbacks */ + /* ___crt_xl_end__ is defined in the TLS Directory support code */ + ___crt_xp_start__ = . ; + *(SORT(.CRT$XP*)) /* Pre-termination */ + ___crt_xp_end__ = . ; + ___crt_xt_start__ = . ; + *(SORT(.CRT$XT*)) /* Termination */ + ___crt_xt_end__ = . ; + } + /* Windows TLS expects .tls$AAA to be at the start and .tls$ZZZ to be + at the end of the .tls section. This is important because _tls_start MUST + be at the beginning of the section to enable SECREL32 relocations with TLS + data. */ + .tls BLOCK(__section_alignment__) : + { + ___tls_start__ = . ; + *(.tls$AAA) + *(.tls) + *(.tls$) + *(SORT(.tls$*)) + *(.tls$ZZZ) + ___tls_end__ = . ; + } + .endjunk BLOCK(__section_alignment__) : + { + /* end is deprecated, don't use it */ + PROVIDE (end = .); + PROVIDE ( _end = .); + __end__ = .; + } + .rsrc BLOCK(__section_alignment__) : + { + *(.rsrc) + *(SORT(.rsrc$*)) + } + .reloc BLOCK(__section_alignment__) : + { + *(.reloc) + } + .stab BLOCK(__section_alignment__) (NOLOAD) : + { + *(.stab) + } + .stabstr BLOCK(__section_alignment__) (NOLOAD) : + { + *(.stabstr) + } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section. Unlike other targets that fake this by putting the + section VMA at 0, the PE format will not allow it. */ + /* DWARF 1.1 and DWARF 2. */ + .debug_aranges BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_aranges) + } + .zdebug_aranges BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_aranges) + } + .debug_pubnames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_pubnames) + } + .zdebug_pubnames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_pubnames) + } + .debug_pubtypes BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_pubtypes) + } + .zdebug_pubtypes BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_pubtypes) + } + /* DWARF 2. */ + .debug_info BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_info .gnu.linkonce.wi.*) + } + .zdebug_info BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_info .zdebug.gnu.linkonce.wi.*) + } + .debug_abbrev BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_abbrev) + } + .zdebug_abbrev BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_abbrev) + } + .debug_line BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_line) + } + .zdebug_line BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_line) + } + .debug_frame BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_frame) + } + .zdebug_frame BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_frame) + } + .debug_str BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_str) + } + .zdebug_str BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_str) + } + .debug_loc BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_loc) + } + .zdebug_loc BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_loc) + } + .debug_macinfo BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_macinfo) + } + .zdebug_macinfo BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_macinfo) + } + /* SGI/MIPS DWARF 2 extensions. */ + .debug_weaknames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_weaknames) + } + .zdebug_weaknames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_weaknames) + } + .debug_funcnames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_funcnames) + } + .zdebug_funcnames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_funcnames) + } + .debug_typenames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_typenames) + } + .zdebug_typenames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_typenames) + } + .debug_varnames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_varnames) + } + .zdebug_varnames BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_varnames) + } + .debug_macro BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_macro) + } + .zdebug_macro BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_macro) + } + /* DWARF 3. */ + .debug_ranges BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_ranges) + } + .zdebug_ranges BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_ranges) + } + /* DWARF 4. */ + .debug_types BLOCK(__section_alignment__) (NOLOAD) : + { + *(.debug_types .gnu.linkonce.wt.*) + } + .zdebug_types BLOCK(__section_alignment__) (NOLOAD) : + { + *(.zdebug_types .zdebug.gnu.linkonce.wt.*) + } +} diff --git a/menu/Makefile b/menu/Makefile deleted file mode 100644 index 22df523..0000000 --- a/menu/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -TARGET = libanimations.a -TOPDIR = .. - -include $(TOPDIR)/defaults.mk - -SRC = menu.c - - -include $(TOPDIR)/rules.mk diff --git a/rfm12/Makefile b/rfm12/Makefile deleted file mode 100644 index 060edd2..0000000 --- a/rfm12/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -TARGET = objects -TOPDIR = .. - -include $(TOPDIR)/defaults.mk - -SRC = rfm12.c borg_rfm12.c - -include $(TOPDIR)/rules.mk diff --git a/rfm12/rfm12.c b/rfm12/rfm12.c deleted file mode 100644 index f75b207..0000000 --- a/rfm12/rfm12.c +++ /dev/null @@ -1,4 +0,0 @@ - -#include "rfm12_config.h" -#include "rfm12_lib/rfm12.c" - diff --git a/rfm12/rfm12.h b/rfm12/rfm12.h deleted file mode 100644 index 39119fb..0000000 --- a/rfm12/rfm12.h +++ /dev/null @@ -1,4 +0,0 @@ - -#include "rfm12_config.h" -#include "rfm12_lib/rfm12.h" - diff --git a/rules.mk b/rules.mk index 55160be..f2978c0 100644 --- a/rules.mk +++ b/rules.mk @@ -1,5 +1,3 @@ - - ############################################################################## # rules for buildung AVR objects @@ -35,17 +33,14 @@ objects_sim: $(OBJECTS_SIM) @ if [ ! -d obj_sim ]; then mkdir obj_sim ; fi @ echo $(OBJECTS_SIM) > obj_sim/.objects - - - clean-common: $(RM) $(TARGET) *.[odasE] *.d.new *~ - $(RM) -r ./obj_avr - $(RM) -r ./obj_sim + $(RM) -r obj_avr + $(RM) -r obj_sim clean: clean-common all: $(MAKE) -C $(TOPDIR) all -include $(TOPDIR)/depend.mk +#include depend.mk diff --git a/scripts/Menuconfig b/scripts/Menuconfig index 2144b48..1abb5e3 100644 --- a/scripts/Menuconfig +++ b/scripts/Menuconfig @@ -1564,7 +1564,7 @@ save_configuration () { echo -n "." DEF_CONFIG="${1:-.config}" - DEF_CONFIG_H="autoconf.h" + DEF_CONFIG_H="src/autoconf.h" CONFIG=.tmpconfig CONFIG_H=.tmpconfig.h @@ -1722,32 +1722,40 @@ echo -n ", parsing" parse_config_files $CONFIG_IN echo "done." -# -# Start the ball rolling from the top. -# -activate_menu MCmenu0 -# -# All done! -# -cleanup1 +if [ -z $2 ]; then # Interactive mode + # + # Start the ball rolling from the top. + # + activate_menu MCmenu0 -# -# Confirm and Save -# -if $DIALOG --backtitle "$backtitle" \ - --yesno "Do you wish to save your new Borg configuration?" 5 60 -then + # + # All done! + # + cleanup1 + + # + # Confirm and Save + # + if $DIALOG --backtitle "$backtitle" \ + --yesno "Do you wish to save your new Borg configuration?" 5 60 + then + save_configuration + echo + echo + echo "*** End of Borg configuration." + echo + else + echo + echo + echo Your Borg configuration changes were NOT saved. + echo + fi +else # Second argument give; noninteractive! + echo "Loading configuration file $2" + load_config_file $2 + cleanup1 save_configuration - echo - echo - echo "*** End of Borg configuration." - echo -else - echo - echo - echo Your Borg configuration changes were NOT saved. - echo fi # Remove log if empty. diff --git a/scrolltext/Makefile b/scrolltext/Makefile deleted file mode 100644 index 3c9c740..0000000 --- a/scrolltext/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -TARGET = objects -TOPDIR = .. - -include $(TOPDIR)/defaults.mk - -SRC = scrolltext3.c - -SRC += $(shell echo $(SCROLLTEXT_FONT) | tr A-Z a-z).c - -include $(TOPDIR)/rules.mk diff --git a/simulator/Makefile.osx b/simulator/Makefile.osx deleted file mode 100644 index 3412484..0000000 --- a/simulator/Makefile.osx +++ /dev/null @@ -1,102 +0,0 @@ -PRG = borgSim -APP = $(PRG).app/Contents/MacOS/$(PRG) -OPTIMIZE = -O2 -LIBS = -lpthread -framework Carbon -framework GLUT -framework OpenGL -framework Foundation -framework AppKit -CC = gcc -LD = ld - -override CFLAGS = -g -Wall -pedantic -std=c99 $(OPTIMIZE) -DOSX_ -$(DEFS) -override LDFLAGS = -Wl --prebind - -OBJ = breakpoint.o font_arial8.o font_small6.o font_uni53.o invader_draw.o \ - invader_init.o invader_proc.o invaders2.o joystick.o main.o menu.o pixel.o \ - program.o scrolltext3.o snake.o trackball.o util.o tetris/input.o \ - tetris/logic.o tetris/piece.o tetris/playfield.o tetris/view.o - -all: Makefile.osx $(APP) - -$(APP): $(OBJ) - test -d $(PRG).app/Contents/MacOS/ || mkdir -p $(PRG).app/Contents/MacOS/ - test -d $(PRG).app/Contents/Resources/ || mkdir -p $(PRG).app/Resources/ - test $(PRG).app/Contents/Rescources/borg3d.icns || cp -f borg3d.icns $(PRG).app/Contents/Rescources/ - $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) $(OBJ) -o $@ - -clean: - rm -rf $(OBJ) $(PRG) $(PRG).app/ - -breakpoint.o: breakpoint.c pixel.h util.h config.h - $(CC) $(CFLAGS) -c -o breakpoint.o breakpoint.c - -font_arial8.o: font_arial8.c font.h - $(CC) $(CFLAGS) -c -o font_arial8.o font_arial8.c - -font_small6.o: font_small6.c font.h - $(CC) $(CFLAGS) -c -o font_small6.o font_small6.c - -font_uni53.o: font_uni53.c font.h - $(CC) $(CFLAGS) -c -o font_uni53.o font_uni53.c - -invader_draw.o: invader_draw.c invaders2.h pixel.h util.h config.h \ - scrolltext.h joystick.h - $(CC) $(CFLAGS) -c -o invader_draw.o invader_draw.c - -invader_init.o: invader_init.c invaders2.h pixel.h util.h config.h \ - scrolltext.h joystick.h - $(CC) $(CFLAGS) -c -o invader_init.o invader_init.c - -invader_proc.o: invader_proc.c invaders2.h pixel.h util.h config.h \ - scrolltext.h joystick.h - $(CC) $(CFLAGS) -c -o invader_proc.o invader_proc.c - -invaders2.o: invaders2.c util.h invaders2.h pixel.h config.h scrolltext.h \ - joystick.h - $(CC) $(CFLAGS) -c -o invaders2.o invaders2.c - -joystick.o: joystick.c joystick.h - $(CC) $(CFLAGS) -c -o joystick.o joystick.c - -main.o: main.c config.h pixel.h util.h program.h menu.h tetris/logic.h \ - tetris/piece.h trackball.h snake.h scrolltext.h - $(CC) $(CFLAGS) -c -o main.o main.c - -menu.o: menu.c menu.h config.h util.h pixel.h joystick.h snake.h \ - tetris/logic.h tetris/piece.h invaders2.h scrolltext.h - $(CC) $(CFLAGS) -c -o menu.o menu.c - -pixel.o: pixel.c pixel.h util.h config.h - $(CC) $(CFLAGS) -c -o pixel.o pixel.c - -program.o: program.c pixel.h util.h config.h program.h joystick.h - $(CC) $(CFLAGS) -c -o program.o program.c - -scrolltext3.o: scrolltext3.c config.h scrolltext.h pixel.h util.h \ - font_arial8.h font.h font_small6.h font_uni53.h - $(CC) $(CFLAGS) -c -o scrolltext3.o scrolltext3.c - -snake.o: snake.c pixel.h util.h config.h joystick.h - $(CC) $(CFLAGS) -c -o snake.o snake.c - -trackball.o: trackball.c trackball.h - $(CC) $(CFLAGS) -c -o trackball.o trackball.c - -util.o: util.c joystick.h - $(CC) $(CFLAGS) -c -o util.o util.c - -tetris/input.o: tetris/input.c joystick.h util.h tetris/input.h - $(CC) $(CFLAGS) -c -o tetris/input.o tetris/input.c - -tetris/logic.o: tetris/logic.c tetris/logic.h tetris/piece.h \ - tetris/playfield.h tetris/view.h tetris/input.h - $(CC) $(CFLAGS) -c -o tetris/logic.o tetris/logic.c - -tetris/piece.o: tetris/piece.c tetris/piece.h - $(CC) $(CFLAGS) -c -o tetris/piece.o tetris/piece.c - -tetris/playfield.o: tetris/playfield.c tetris/playfield.h tetris/piece.h - $(CC) $(CFLAGS) -c -o tetris/playfield.o tetris/playfield.c - -tetris/view.o: tetris/view.c config.h pixel.h util.h scrolltext.h \ - tetris/logic.h tetris/piece.h tetris/playfield.h tetris/view.h - $(CC) $(CFLAGS) -c -o tetris/view.o tetris/view.c - diff --git a/animations/Makefile b/src/animations/Makefile similarity index 82% rename from animations/Makefile rename to src/animations/Makefile index 248f9c8..585edb9 100644 --- a/animations/Makefile +++ b/src/animations/Makefile @@ -1,7 +1,8 @@ -TARGET = libanimations.a -TOPDIR = .. +MAKETOPDIR = ../.. -include $(TOPDIR)/defaults.mk +TARGET = libanimations.a + +include $(MAKETOPDIR)/defaults.mk SRC = program.c @@ -29,6 +30,10 @@ ifeq ($(ANIMATION_MHERWEG),y) SRC += mherweg.c endif +ifeq ($(ANIMATION_MOIRE),y) + SRC += moire.c +endif + ifeq ($(ANIMATION_BREAKOUT),y) SRC += breakout_demo.c endif @@ -53,4 +58,6 @@ ifeq ($(ANIMATION_TIME),y) SRC += borg_time.c endif -include $(TOPDIR)/rules.mk +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/animations/bitmapscroller/Makefile b/src/animations/bitmapscroller/Makefile similarity index 71% rename from animations/bitmapscroller/Makefile rename to src/animations/bitmapscroller/Makefile index 8779382..2bdc1c7 100644 --- a/animations/bitmapscroller/Makefile +++ b/src/animations/bitmapscroller/Makefile @@ -1,6 +1,6 @@ -TOPDIR = ../.. +MAKETOPDIR = ../../.. -include $(TOPDIR)/defaults.mk +include $(MAKETOPDIR)/defaults.mk ifeq ($(ANIMATION_BMSCROLLER),y) SRC = bitmapscroller.c @@ -22,4 +22,6 @@ ifeq ($(ANIMATION_FAIRYDUST),y) SRC += fairydust.c endif -include $(TOPDIR)/rules.mk +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/animations/bitmapscroller/amphibian.c b/src/animations/bitmapscroller/amphibian.c similarity index 100% rename from animations/bitmapscroller/amphibian.c rename to src/animations/bitmapscroller/amphibian.c diff --git a/animations/bitmapscroller/amphibian.h b/src/animations/bitmapscroller/amphibian.h similarity index 100% rename from animations/bitmapscroller/amphibian.h rename to src/animations/bitmapscroller/amphibian.h diff --git a/animations/bitmapscroller/bitmapscroller.c b/src/animations/bitmapscroller/bitmapscroller.c similarity index 100% rename from animations/bitmapscroller/bitmapscroller.c rename to src/animations/bitmapscroller/bitmapscroller.c diff --git a/animations/bitmapscroller/bitmapscroller.h b/src/animations/bitmapscroller/bitmapscroller.h similarity index 100% rename from animations/bitmapscroller/bitmapscroller.h rename to src/animations/bitmapscroller/bitmapscroller.h diff --git a/animations/bitmapscroller/config.in b/src/animations/bitmapscroller/config.in similarity index 100% rename from animations/bitmapscroller/config.in rename to src/animations/bitmapscroller/config.in diff --git a/animations/bitmapscroller/fairydust.c b/src/animations/bitmapscroller/fairydust.c similarity index 100% rename from animations/bitmapscroller/fairydust.c rename to src/animations/bitmapscroller/fairydust.c diff --git a/animations/bitmapscroller/fairydust.h b/src/animations/bitmapscroller/fairydust.h similarity index 100% rename from animations/bitmapscroller/fairydust.h rename to src/animations/bitmapscroller/fairydust.h diff --git a/animations/bitmapscroller/laborlogo.c b/src/animations/bitmapscroller/laborlogo.c similarity index 100% rename from animations/bitmapscroller/laborlogo.c rename to src/animations/bitmapscroller/laborlogo.c diff --git a/animations/bitmapscroller/laborlogo.h b/src/animations/bitmapscroller/laborlogo.h similarity index 100% rename from animations/bitmapscroller/laborlogo.h rename to src/animations/bitmapscroller/laborlogo.h diff --git a/animations/bitmapscroller/outofspec.c b/src/animations/bitmapscroller/outofspec.c similarity index 100% rename from animations/bitmapscroller/outofspec.c rename to src/animations/bitmapscroller/outofspec.c diff --git a/animations/bitmapscroller/outofspec.h b/src/animations/bitmapscroller/outofspec.h similarity index 100% rename from animations/bitmapscroller/outofspec.h rename to src/animations/bitmapscroller/outofspec.h diff --git a/animations/blackhole.c b/src/animations/blackhole.c similarity index 100% rename from animations/blackhole.c rename to src/animations/blackhole.c diff --git a/animations/blackhole.h b/src/animations/blackhole.h similarity index 100% rename from animations/blackhole.h rename to src/animations/blackhole.h diff --git a/animations/borg_time.c b/src/animations/borg_time.c similarity index 100% rename from animations/borg_time.c rename to src/animations/borg_time.c diff --git a/animations/borg_time.h b/src/animations/borg_time.h similarity index 94% rename from animations/borg_time.h rename to src/animations/borg_time.h index d71c032..520d105 100644 --- a/animations/borg_time.h +++ b/src/animations/borg_time.h @@ -7,6 +7,8 @@ #ifndef BORG_TIME_H_ #define BORG_TIME_H_ +#include + //send a time request packet via can void time_request(void); diff --git a/animations/breakout_demo.c b/src/animations/breakout_demo.c similarity index 100% rename from animations/breakout_demo.c rename to src/animations/breakout_demo.c diff --git a/animations/breakout_demo.h b/src/animations/breakout_demo.h similarity index 100% rename from animations/breakout_demo.h rename to src/animations/breakout_demo.h diff --git a/animations/config.in b/src/animations/config.in similarity index 95% rename from animations/config.in rename to src/animations/config.in index fe99f3a..2d21fdd 100644 --- a/animations/config.in +++ b/src/animations/config.in @@ -42,6 +42,7 @@ comment "Animations" dep_bool "Breakout Demo" ANIMATION_BREAKOUT $GAME_BREAKOUT dep_bool "Martin Herweg" ANIMATION_MHERWEG $RANDOM_SUPPORT + dep_bool "Moire" ANIMATION_MOIRE $RANDOM_SUPPORT dep_bool "Langton Ant" ANIMATION_LTN_ANT $RANDOM_SUPPORT dep_bool_menu "Time Display" ANIMATION_TIME $SCROLLTEXT_SUPPORT $LAP_TIME_EXTENSION @@ -49,7 +50,7 @@ comment "Animations" int "Request Timeout (ms)" TIME_UPDATE_TIMEOUT 50 endmenu - source animations/bitmapscroller/config.in + source src/animations/bitmapscroller/config.in mainmenu_option next_comment comment "Fixed-point math patterns" diff --git a/animations/flyingdots.c b/src/animations/flyingdots.c similarity index 100% rename from animations/flyingdots.c rename to src/animations/flyingdots.c diff --git a/animations/flyingdots.h b/src/animations/flyingdots.h similarity index 100% rename from animations/flyingdots.h rename to src/animations/flyingdots.h diff --git a/animations/fpmath_patterns.c b/src/animations/fpmath_patterns.c similarity index 100% rename from animations/fpmath_patterns.c rename to src/animations/fpmath_patterns.c diff --git a/animations/fpmath_patterns.h b/src/animations/fpmath_patterns.h similarity index 100% rename from animations/fpmath_patterns.h rename to src/animations/fpmath_patterns.h diff --git a/animations/gameoflife.c b/src/animations/gameoflife.c similarity index 100% rename from animations/gameoflife.c rename to src/animations/gameoflife.c diff --git a/animations/gameoflife.h b/src/animations/gameoflife.h similarity index 100% rename from animations/gameoflife.h rename to src/animations/gameoflife.h diff --git a/animations/ltn_ant.c b/src/animations/ltn_ant.c similarity index 100% rename from animations/ltn_ant.c rename to src/animations/ltn_ant.c diff --git a/animations/ltn_ant.h b/src/animations/ltn_ant.h similarity index 100% rename from animations/ltn_ant.h rename to src/animations/ltn_ant.h diff --git a/animations/matrix.c b/src/animations/matrix.c similarity index 100% rename from animations/matrix.c rename to src/animations/matrix.c diff --git a/animations/matrix.h b/src/animations/matrix.h similarity index 100% rename from animations/matrix.h rename to src/animations/matrix.h diff --git a/animations/mherweg.c b/src/animations/mherweg.c similarity index 86% rename from animations/mherweg.c rename to src/animations/mherweg.c index 94a9c33..6f56575 100644 --- a/animations/mherweg.c +++ b/src/animations/mherweg.c @@ -27,51 +27,6 @@ #define PGM(x) pgm_read_byte(&(x)) -#if NUM_ROWS < 64 && NUM_COLS < 64 - /** use 8 bit operands where feasible */ - typedef signed char operand_t; -#else - /** use 16 bit operands if either width or height are >= 64 */ - typedef int operand_t; -#endif - - -/** - * An implementation of Bresenham's line drawing algorithm. - * @param p1 first coordinate of the line - * @param p2 second coordinate of the line - * @param color brightness level of the line - */ -static void line(pixel p1, - pixel const p2, - unsigned char const color) -{ - operand_t const dx = p1.x < p2.x ? p2.x - p1.x : p1.x - p2.x; - operand_t const sx = p1.x < p2.x ? 1 : -1; - operand_t const dy = p1.y < p2.y ? p2.y - p1.y : p1.y - p2.y; - operand_t const sy = p1.y < p2.y ? 1 : -1; - operand_t error = dx - dy; - - while(1) - { - setpixel(p1, color); - if ((p1.x == p2.x) && (p1.y == p2.y)) - break; - operand_t const error2 = 2 * error; - if (error2 > -dy) - { - error -= dy; - p1.x += sx; - } - if (error2 < dx) - { - error += dx; - p1.y += sy; - } - } -} - - /** * Draws a rectangle at the given coordinates. * @param p coordinate of the rectangle's upper right corner diff --git a/animations/mherweg.h b/src/animations/mherweg.h similarity index 100% rename from animations/mherweg.h rename to src/animations/mherweg.h diff --git a/src/animations/moire.c b/src/animations/moire.c new file mode 100644 index 0000000..ce35b30 --- /dev/null +++ b/src/animations/moire.c @@ -0,0 +1,88 @@ +/** + * \defgroup moire A moire like pattern. + * @{ + */ + +/** + * @file moire.c + * @brief Implementation of a simple moire like pattern. + * @author Christian Kroll + */ + +#include "../config.h" +#include "../pixel.h" +#include "../util.h" + +/** + * Number of pixels of the complete border. + */ +#define NUMBER_OF_BORDER_PIXELS (2u * UNUM_COLS + 2u * (UNUM_ROWS - 2u)) + +/** + * Draws a moire like pattern. Works best if the number of border pixels is a + * multiple of the size of the gradient color map. + */ +void moire(void) +{ + // add rotating color map +#if NUMPLANE == 3 + static unsigned char const gradient[] = {0, 1, 2, 3, 2, 1}; +#else + static unsigned char gradient[NUMPLANE * 2u] = {0}; + for (unsigned char i = 1; i <= NUMPLANE; ++i) + { + gradient[i] = i; + gradient[(NUMPLANE * 2) - i] = i; + } +#endif + + unsigned int cycles = 30000; + unsigned char pos = 0, color_index = 0; + pixel p1 = (pixel){0 ,0}; + + while(cycles--) + { + // walk around the border; do that by mapping a linear increasing value + // to appropriate screen coordinates + + // first pixel is between top right and top left corner + if (pos < NUM_COLS) + { + p1.x = pos; + } + // first pixel is between top left and bottom left corner + else if (pos < (NUM_COLS + NUM_ROWS - 1)) + { + p1.y = pos - (NUM_COLS - 1); + } + // first pixel is between bottom left and bottom right corner + else if (pos < (2 * NUM_COLS + NUM_ROWS - 2)) + { + p1.x = 2 * NUM_COLS + NUM_ROWS - 3 - pos; + } + // first pixel is between bottom right and top left corner + else + { + p1.y = 3 * NUM_COLS + NUM_ROWS - 4 - pos; + } + + // second pixel in opposite direction + pixel const p2 = (pixel){NUM_COLS - 1 - p1.x, NUM_ROWS - 1 - p1.y}; + + // draw line right accross the display and switch to next color + line(p1, p2, gradient[color_index++]); + + // if we have reached the origin, reset position, rotate color index and + // wait for 40 ms (25 fps) to make the frame visible for human viewers + if (++pos == NUMBER_OF_BORDER_PIXELS) + { + pos = 0; + ++color_index; + wait(40); + } + // ensure the color index keeps within bounds + color_index %= (2u * NUMPLANE); + } +} + +/*@}*/ diff --git a/src/animations/moire.h b/src/animations/moire.h new file mode 100644 index 0000000..9749025 --- /dev/null +++ b/src/animations/moire.h @@ -0,0 +1,19 @@ +/** + * \defgroup moire A moire like pattern. + * @{ + */ + +/** + * @file moire.h + * @brief Interface file for a moire pattern implementation. + * @author Christian Kroll + */ + +#ifndef MOIRE_H_ +#define MOIRE_H_ + +void moire(void); + +#endif /* MOIRE_H_ */ + +/*@}*/ diff --git a/animations/program.c b/src/animations/program.c similarity index 100% rename from animations/program.c rename to src/animations/program.c diff --git a/animations/program.h b/src/animations/program.h similarity index 100% rename from animations/program.h rename to src/animations/program.h diff --git a/animations/snake.c b/src/animations/snake.c similarity index 100% rename from animations/snake.c rename to src/animations/snake.c diff --git a/animations/snake.h b/src/animations/snake.h similarity index 100% rename from animations/snake.h rename to src/animations/snake.h diff --git a/animations/squares.c b/src/animations/squares.c similarity index 100% rename from animations/squares.c rename to src/animations/squares.c diff --git a/animations/squares.h b/src/animations/squares.h similarity index 100% rename from animations/squares.h rename to src/animations/squares.h diff --git a/animations/stonefly.c b/src/animations/stonefly.c similarity index 100% rename from animations/stonefly.c rename to src/animations/stonefly.c diff --git a/animations/stonefly.h b/src/animations/stonefly.h similarity index 100% rename from animations/stonefly.h rename to src/animations/stonefly.h diff --git a/borg_hw/Makefile b/src/borg_hw/Makefile similarity index 89% rename from borg_hw/Makefile rename to src/borg_hw/Makefile index aeb6ee8..78c6d38 100644 --- a/borg_hw/Makefile +++ b/src/borg_hw/Makefile @@ -1,9 +1,10 @@ +MAKETOPDIR = ../.. + TARGET = libborg_hw.a -TOPDIR = .. SRC_SIM := -include $(TOPDIR)/defaults.mk +include $(MAKETOPDIR)/defaults.mk ifeq ($(BORG_HW),HW_BORG_16) @@ -66,4 +67,6 @@ ifeq ($(SRC),'') $(error no valid hardware driver selected ) endif -include $(TOPDIR)/rules.mk +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/borg_hw/borg_hw.h b/src/borg_hw/borg_hw.h similarity index 100% rename from borg_hw/borg_hw.h rename to src/borg_hw/borg_hw.h diff --git a/borg_hw/borg_hw_ancient.c b/src/borg_hw/borg_hw_ancient.c similarity index 89% rename from borg_hw/borg_hw_ancient.c rename to src/borg_hw/borg_hw_ancient.c index 621cfc1..e4772b4 100644 --- a/borg_hw/borg_hw_ancient.c +++ b/src/borg_hw/borg_hw_ancient.c @@ -62,7 +62,7 @@ void timer0_off(){ COLPORT = 0; ROWPORT = 0; -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x00; TCCR0B = 0x00; TIMSK0 = 0; @@ -86,7 +86,7 @@ static void timer0_on(){ */ -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x02; // CTC Mode TCCR0B = 0x03; // clk/64 TCNT0 = 0x00; // reset timer diff --git a/borg_hw/borg_hw_andreborg.c b/src/borg_hw/borg_hw_andreborg.c similarity index 91% rename from borg_hw/borg_hw_andreborg.c rename to src/borg_hw/borg_hw_andreborg.c index 1682e48..f665601 100644 --- a/borg_hw/borg_hw_andreborg.c +++ b/src/borg_hw/borg_hw_andreborg.c @@ -34,7 +34,7 @@ #define COLDDR2 DDR(COLPORT2) #define ROWDDR DDR(ROWPORT) -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) /* more ifdef magic :-( */ #define OCR0 OCR0A #define TIMER0_COMP_vect TIMER0_COMPA_vect @@ -120,7 +120,7 @@ void timer0_off() { COLPORT2 = 0; ROWPORT = 0; -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x00; TCCR0B = 0x00; #else @@ -141,7 +141,7 @@ static void timer0_on() { 1 0 1 clk/1024 */ -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x02; // CTC Mode TCCR0B = 0x03; // clk/64 TCNT0 = 0; // reset timer diff --git a/borg_hw/borg_hw_borg16.c b/src/borg_hw/borg_hw_borg16.c similarity index 92% rename from borg_hw/borg_hw_borg16.c rename to src/borg_hw/borg_hw_borg16.c index adf0176..1d12e4e 100644 --- a/borg_hw/borg_hw_borg16.c +++ b/src/borg_hw/borg_hw_borg16.c @@ -33,7 +33,7 @@ #define COLDDR2 DDR(COLPORT2) #define ROWDDR DDR(ROWPORT) -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) /* more ifdef magic :-( */ #define OCR0 OCR0A #define TIMER0_COMP_vect TIMER0_COMPA_vect @@ -153,7 +153,7 @@ void timer0_off() { COLPORT2 = 0; ROWPORT = 0; -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x00; TCCR0B = 0x00; #else @@ -175,7 +175,7 @@ static void timer0_on() { 1 0 1 clk/1024 */ -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x02; // CTC Mode TCCR0B = 0x04; // clk/256 TCNT0 = 0; // reset timer diff --git a/borg_hw/borg_hw_borg16_hgmod.c b/src/borg_hw/borg_hw_borg16_hgmod.c similarity index 96% rename from borg_hw/borg_hw_borg16_hgmod.c rename to src/borg_hw/borg_hw_borg16_hgmod.c index 7d89f25..1625688 100644 --- a/borg_hw/borg_hw_borg16_hgmod.c +++ b/src/borg_hw/borg_hw_borg16_hgmod.c @@ -34,7 +34,7 @@ } /* more ifdef magic :-( */ -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) #define OCR0 OCR0A #define TIMER0_COMP_vect TIMER0_COMPA_vect #endif @@ -195,7 +195,7 @@ void timer0_off() { TLCPORT = 0; ROWPORT = 0; - #if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) + #if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x00; TCCR0B = 0x00; #else @@ -221,7 +221,7 @@ static void timer0_on() { * 1 0 1 clk/1024 */ - #if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) + #if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x02; // CTC Mode TCCR0B = 0x04; // clk/256 TCNT0 = 0; // reset timer diff --git a/borg_hw/borg_hw_borg_ls.c b/src/borg_hw/borg_hw_borg_ls.c similarity index 100% rename from borg_hw/borg_hw_borg_ls.c rename to src/borg_hw/borg_hw_borg_ls.c diff --git a/borg_hw/borg_hw_borg_lsjo.c b/src/borg_hw/borg_hw_borg_lsjo.c similarity index 100% rename from borg_hw/borg_hw_borg_lsjo.c rename to src/borg_hw/borg_hw_borg_lsjo.c diff --git a/borg_hw/borg_hw_borg_mh.c b/src/borg_hw/borg_hw_borg_mh.c similarity index 100% rename from borg_hw/borg_hw_borg_mh.c rename to src/borg_hw/borg_hw_borg_mh.c diff --git a/borg_hw/borg_hw_borg_mini.c b/src/borg_hw/borg_hw_borg_mini.c similarity index 100% rename from borg_hw/borg_hw_borg_mini.c rename to src/borg_hw/borg_hw_borg_mini.c diff --git a/borg_hw/borg_hw_gigaborg.c b/src/borg_hw/borg_hw_gigaborg.c similarity index 88% rename from borg_hw/borg_hw_gigaborg.c rename to src/borg_hw/borg_hw_gigaborg.c index 57209c3..e70ceb0 100644 --- a/borg_hw/borg_hw_gigaborg.c +++ b/src/borg_hw/borg_hw_gigaborg.c @@ -33,7 +33,7 @@ #define COLDDR2 DDR(COLPORT2) #define ROWDDR DDR(ROWPORT) -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) /* more ifdef magic :-( */ #define OCR0 OCR0A #define TIMER0_COMP_vect TIMER0_COMPA_vect @@ -62,7 +62,7 @@ void timer0_off() { COLPORT2 = 0; ROWPORT = 0; -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x00; TCCR0B = 0x00; #else @@ -83,7 +83,7 @@ void timer0_on() { 1 0 0 clk/256 1 0 1 clk/1024 */ -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x02; // CTC Mode TCCR0B = 0x04; // clk/256 TCNT0 = 0; // reset timer diff --git a/borg_hw/borg_hw_ledbrett.c b/src/borg_hw/borg_hw_ledbrett.c similarity index 95% rename from borg_hw/borg_hw_ledbrett.c rename to src/borg_hw/borg_hw_ledbrett.c index f55c202..5d32f4b 100644 --- a/borg_hw/borg_hw_ledbrett.c +++ b/src/borg_hw/borg_hw_ledbrett.c @@ -31,7 +31,7 @@ #define MUX_ROWS 4 -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) /* more ifdef magic :-( */ #define OCR0 OCR0A #define SIG_OUTPUT_COMPARE0 SIG_OUTPUT_COMPARE0A @@ -283,7 +283,7 @@ void timer0_off() { ROW3_OFF(); ROW4_OFF(); -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x00; TCCR0B = 0x00; #else @@ -305,7 +305,7 @@ static void timer0_on() { 1 0 1 clk/1024 */ -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) TCCR0A = 0x02; // CTC Mode TCCR0B = 0x04; // clk/256 TCNT0 = 0; // reset timer diff --git a/borg_hw/borg_hw_panel_one.c b/src/borg_hw/borg_hw_panel_one.c similarity index 100% rename from borg_hw/borg_hw_panel_one.c rename to src/borg_hw/borg_hw_panel_one.c diff --git a/borg_hw/borg_hw_pd1165.c b/src/borg_hw/borg_hw_pd1165.c similarity index 100% rename from borg_hw/borg_hw_pd1165.c rename to src/borg_hw/borg_hw_pd1165.c diff --git a/borg_hw/borg_hw_pingpong.c b/src/borg_hw/borg_hw_pingpong.c similarity index 100% rename from borg_hw/borg_hw_pingpong.c rename to src/borg_hw/borg_hw_pingpong.c diff --git a/borg_hw/borg_hw_rotor.c b/src/borg_hw/borg_hw_rotor.c similarity index 100% rename from borg_hw/borg_hw_rotor.c rename to src/borg_hw/borg_hw_rotor.c diff --git a/borg_hw/config.in b/src/borg_hw/config.in similarity index 73% rename from borg_hw/config.in rename to src/borg_hw/config.in index 12ee793..d494ec3 100644 --- a/borg_hw/config.in +++ b/src/borg_hw/config.in @@ -26,59 +26,59 @@ choice 'Hardware Driver' \ if [ "$BORG_HW" == "HW_BORG_16" ] ; then - source borg_hw/config_borg16.in + source src/borg_hw/config_borg16.in fi if [ "$BORG_HW" == "HW_BORG_16_HGM" ] ; then - source borg_hw/config_borg16_hgmod.in + source src/borg_hw/config_borg16_hgmod.in fi if [ "$BORG_HW" == "HW_BORG_ANDRE" ] ; then - source borg_hw/config_andreborg.in + source src/borg_hw/config_andreborg.in fi if [ "$BORG_HW" == "HW_BORG_LS" ] ; then - source borg_hw/config_borg_ls.in + source src/borg_hw/config_borg_ls.in fi if [ "$BORG_HW" == "HW_BORG_MH" ] ; then - source borg_hw/config_borg_mh.in + source src/borg_hw/config_borg_mh.in fi if [ "$BORG_HW" == "HW_BORG_LSJO" ] ; then - source borg_hw/config_borg_lsjo.in + source src/borg_hw/config_borg_lsjo.in fi if [ "$BORG_HW" == "HW_LEDBRETT" ] ; then - source borg_hw/config_ledbrett.in + source src/borg_hw/config_ledbrett.in fi if [ "$BORG_HW" == "HW_BORG_MINI" ] ; then - source borg_hw/config_borg_mini.in + source src/borg_hw/config_borg_mini.in fi if [ "$BORG_HW" == "HW_PANEL_ONE" ] ; then - source borg_hw/config_panel_one.in + source src/borg_hw/config_panel_one.in fi if [ "$BORG_HW" == "HW_PD1165" ] ; then - source borg_hw/config_pd1165.in + source src/borg_hw/config_pd1165.in fi if [ "$BORG_HW" == "HW_PINGPONG" ] ; then - source borg_hw/config_pingpong.in + source src/borg_hw/config_pingpong.in fi if [ "$BORG_HW" == "HW_ROTOR" ] ; then - source borg_hw/config_rotor.in + source src/borg_hw/config_rotor.in fi if [ "$BORG_HW" == "HW_GIGABORG" ] ; then - source borg_hw/config_gigaborg.in + source src/borg_hw/config_gigaborg.in fi if [ "$BORG_HW" == "HW_ANCIENTBORG" ] ; then - source borg_hw/config_ancient.in + source src/borg_hw/config_ancient.in fi endmenu diff --git a/borg_hw/config_ancient.in b/src/borg_hw/config_ancient.in similarity index 100% rename from borg_hw/config_ancient.in rename to src/borg_hw/config_ancient.in diff --git a/borg_hw/config_andreborg.in b/src/borg_hw/config_andreborg.in similarity index 100% rename from borg_hw/config_andreborg.in rename to src/borg_hw/config_andreborg.in diff --git a/borg_hw/config_borg16.in b/src/borg_hw/config_borg16.in similarity index 100% rename from borg_hw/config_borg16.in rename to src/borg_hw/config_borg16.in diff --git a/borg_hw/config_borg16_hgmod.in b/src/borg_hw/config_borg16_hgmod.in similarity index 100% rename from borg_hw/config_borg16_hgmod.in rename to src/borg_hw/config_borg16_hgmod.in diff --git a/borg_hw/config_borg_ls.in b/src/borg_hw/config_borg_ls.in similarity index 100% rename from borg_hw/config_borg_ls.in rename to src/borg_hw/config_borg_ls.in diff --git a/borg_hw/config_borg_lsjo.in b/src/borg_hw/config_borg_lsjo.in similarity index 100% rename from borg_hw/config_borg_lsjo.in rename to src/borg_hw/config_borg_lsjo.in diff --git a/borg_hw/config_borg_mh.in b/src/borg_hw/config_borg_mh.in similarity index 100% rename from borg_hw/config_borg_mh.in rename to src/borg_hw/config_borg_mh.in diff --git a/borg_hw/config_borg_mini.in b/src/borg_hw/config_borg_mini.in similarity index 100% rename from borg_hw/config_borg_mini.in rename to src/borg_hw/config_borg_mini.in diff --git a/borg_hw/config_gigaborg.in b/src/borg_hw/config_gigaborg.in similarity index 100% rename from borg_hw/config_gigaborg.in rename to src/borg_hw/config_gigaborg.in diff --git a/borg_hw/config_ledbrett.in b/src/borg_hw/config_ledbrett.in similarity index 100% rename from borg_hw/config_ledbrett.in rename to src/borg_hw/config_ledbrett.in diff --git a/borg_hw/config_panel_one.in b/src/borg_hw/config_panel_one.in similarity index 100% rename from borg_hw/config_panel_one.in rename to src/borg_hw/config_panel_one.in diff --git a/borg_hw/config_pd1165.in b/src/borg_hw/config_pd1165.in similarity index 100% rename from borg_hw/config_pd1165.in rename to src/borg_hw/config_pd1165.in diff --git a/borg_hw/config_pingpong.in b/src/borg_hw/config_pingpong.in similarity index 100% rename from borg_hw/config_pingpong.in rename to src/borg_hw/config_pingpong.in diff --git a/borg_hw/config_rotor.in b/src/borg_hw/config_rotor.in similarity index 100% rename from borg_hw/config_rotor.in rename to src/borg_hw/config_rotor.in diff --git a/src/can/Makefile b/src/can/Makefile new file mode 100644 index 0000000..6124560 --- /dev/null +++ b/src/can/Makefile @@ -0,0 +1,16 @@ +MAKETOPDIR = ../.. + +TARGET = libcan.a + +include $(MAKETOPDIR)/defaults.mk + +ifeq ($(CAN_SUPPORT),y) + SRC = can.c + SRC += borg_can.c + SRC += lap.c + SRC += spi.c +endif + +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/can/borg_can.c b/src/can/borg_can.c similarity index 100% rename from can/borg_can.c rename to src/can/borg_can.c diff --git a/can/borg_can.h b/src/can/borg_can.h similarity index 100% rename from can/borg_can.h rename to src/can/borg_can.h diff --git a/can/can.c b/src/can/can.c similarity index 98% rename from can/can.c rename to src/can/can.c index 0f6f539..9d92acc 100644 --- a/can/can.c +++ b/src/can/can.c @@ -395,7 +395,13 @@ unsigned char mcp_status(); #else //this turns on INT0 on the Atmel MCUCR |= (1< -#else - #include - - void eeprom_write_byte (uint8_t *p, uint8_t value); - void eeprom_write_word (uint16_t *p, uint16_t value); - - uint8_t eeprom_read_byte (const uint8_t *p); - uint16_t eeprom_read_word (const uint16_t *p); - - #define eeprom_busy_wait() - #define EEMEM __attribute__((section(".eeprom"))) - -#endif + +//EEPPROM compatibility support for simulator + +#ifdef AVR + #include +#else + #include + + void eeprom_write_byte (uint8_t *p, uint8_t value); + void eeprom_write_word (uint16_t *p, uint16_t value); + + uint8_t eeprom_read_byte (const uint8_t *p); + uint16_t eeprom_read_word (const uint16_t *p); + + #define eeprom_busy_wait() + #define EEMEM __attribute__((section(".eeprom"))) + +#endif diff --git a/compat/interrupt.h b/src/compat/interrupt.h similarity index 90% rename from compat/interrupt.h rename to src/compat/interrupt.h index 8871ad9..079d96b 100644 --- a/compat/interrupt.h +++ b/src/compat/interrupt.h @@ -1,3 +1,3 @@ - -#define sei() -#define cli() + +#define sei() +#define cli() diff --git a/compat/pgmspace.h b/src/compat/pgmspace.h similarity index 100% rename from compat/pgmspace.h rename to src/compat/pgmspace.h diff --git a/config.h b/src/config.h similarity index 100% rename from config.h rename to src/config.h diff --git a/display_loop.c b/src/display_loop.c similarity index 97% rename from display_loop.c rename to src/display_loop.c index 75d1268..42929e2 100644 --- a/display_loop.c +++ b/src/display_loop.c @@ -18,6 +18,7 @@ #include "animations/bitmapscroller/fairydust.h" #include "animations/fpmath_patterns.h" #include "animations/mherweg.h" +#include "animations/moire.h" #include "animations/blackhole.h" #include "animations/squares.h" #ifdef ANIMATION_TIME @@ -36,6 +37,9 @@ #ifdef SMALLANIMATION_COLWALK # include "smallani/colwalk.h" #endif +#ifdef SMALLANIMATION_ROWBOUNCE +# include "smallani/rowbounce.h" +#endif #ifdef SMALLANIMATION_COLBOUNCE # include "smallani/colbounce.h" #endif @@ -180,62 +184,68 @@ void display_loop(){ break; #endif -#ifdef ANIMATION_TIME +#ifdef ANIMATION_MOIRE case 15: + moire(); + break; +#endif + +#ifdef ANIMATION_TIME + case 16: time_anim(); break; #endif #ifdef ANIMATION_LTN_ANT - case 16: + case 17: ltn_ant(); break; #endif #ifdef ANIMATION_LABORLOGO - case 17: + case 18: laborlogo(); break; #endif #ifdef ANIMATION_AMPHIBIAN - case 18: + case 19: amphibian(); break; #endif #ifdef ANIMATION_LOGO_OOS - case 19: + case 20: logo_OutOfSpec(); break; #endif #ifdef ANIMATION_FAIRYDUST - case 20: + case 21: fairydust(); break; #endif #ifdef ANIMATION_PLASMA - case 21: + case 22: plasma(); break; #endif #ifdef ANIMATION_PSYCHEDELIC - case 22: + case 23: psychedelic(); break; #endif #ifdef ANIMATION_BLACKHOLE - case 23: + case 24: blackhole(); break; #endif #ifdef ANIMATION_SQUARES - case 24: + case 25: squares(); break; #endif diff --git a/display_loop.h b/src/display_loop.h similarity index 93% rename from display_loop.h rename to src/display_loop.h index 9ac632f..66cce67 100644 --- a/display_loop.h +++ b/src/display_loop.h @@ -1,4 +1,4 @@ - -void display_loop(); - -extern jmp_buf newmode_jmpbuf; + +void display_loop(); + +extern jmp_buf newmode_jmpbuf; diff --git a/eeprom_reserve.c b/src/eeprom_reserve.c similarity index 100% rename from eeprom_reserve.c rename to src/eeprom_reserve.c diff --git a/src/games/breakout/Makefile b/src/games/breakout/Makefile new file mode 100644 index 0000000..498a826 --- /dev/null +++ b/src/games/breakout/Makefile @@ -0,0 +1,13 @@ +MAKETOPDIR = ../../.. + +TARGET = + +include $(MAKETOPDIR)/defaults.mk + +ifeq ($(GAME_BREAKOUT),y) + SRC = breakout.c playfield.c rebound.c score.c level.c ball.c messages.c +endif + +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/games/breakout/ball.c b/src/games/breakout/ball.c similarity index 100% rename from games/breakout/ball.c rename to src/games/breakout/ball.c diff --git a/games/breakout/ball.h b/src/games/breakout/ball.h similarity index 100% rename from games/breakout/ball.h rename to src/games/breakout/ball.h diff --git a/games/breakout/breakout.c b/src/games/breakout/breakout.c similarity index 100% rename from games/breakout/breakout.c rename to src/games/breakout/breakout.c diff --git a/games/breakout/breakout.h b/src/games/breakout/breakout.h similarity index 100% rename from games/breakout/breakout.h rename to src/games/breakout/breakout.h diff --git a/games/breakout/common.h b/src/games/breakout/common.h similarity index 100% rename from games/breakout/common.h rename to src/games/breakout/common.h diff --git a/games/breakout/config.h b/src/games/breakout/config.h similarity index 100% rename from games/breakout/config.h rename to src/games/breakout/config.h diff --git a/games/breakout/level.c b/src/games/breakout/level.c similarity index 100% rename from games/breakout/level.c rename to src/games/breakout/level.c diff --git a/games/breakout/level.h b/src/games/breakout/level.h similarity index 100% rename from games/breakout/level.h rename to src/games/breakout/level.h diff --git a/games/breakout/messages.c b/src/games/breakout/messages.c similarity index 100% rename from games/breakout/messages.c rename to src/games/breakout/messages.c diff --git a/games/breakout/messages.h b/src/games/breakout/messages.h similarity index 100% rename from games/breakout/messages.h rename to src/games/breakout/messages.h diff --git a/games/breakout/playfield.c b/src/games/breakout/playfield.c similarity index 100% rename from games/breakout/playfield.c rename to src/games/breakout/playfield.c diff --git a/games/breakout/playfield.h b/src/games/breakout/playfield.h similarity index 100% rename from games/breakout/playfield.h rename to src/games/breakout/playfield.h diff --git a/games/breakout/rebound.c b/src/games/breakout/rebound.c similarity index 100% rename from games/breakout/rebound.c rename to src/games/breakout/rebound.c diff --git a/games/breakout/rebound.h b/src/games/breakout/rebound.h similarity index 100% rename from games/breakout/rebound.h rename to src/games/breakout/rebound.h diff --git a/games/breakout/score.c b/src/games/breakout/score.c similarity index 100% rename from games/breakout/score.c rename to src/games/breakout/score.c diff --git a/games/breakout/score.h b/src/games/breakout/score.h similarity index 100% rename from games/breakout/score.h rename to src/games/breakout/score.h diff --git a/games/config.in b/src/games/config.in similarity index 100% rename from games/config.in rename to src/games/config.in diff --git a/games/games.mk b/src/games/games.mk similarity index 51% rename from games/games.mk rename to src/games/games.mk index 2c5003c..e832e7a 100644 --- a/games/games.mk +++ b/src/games/games.mk @@ -1,26 +1,26 @@ - -ifeq ($(GAME_TETRIS_CORE),y) - SUBDIRS += games/tetris -endif - -ifeq ($(GAME_SPACE_INVADERS),y) - SUBDIRS += games/space_invaders -endif - -ifeq ($(GAME_SNAKE),y) - SUBDIRS += games/snake -endif - -ifeq ($(ANIMATION_SNAKE),y) - ifneq ($(GAME_SNAKE),y) - SUBDIRS += games/snake - endif -endif - -ifeq ($(GAME_BREAKOUT),y) - SUBDIRS += games/breakout -endif - -ifeq ($(GAME_KART),y) - SUBDIRS += games/kart -endif +ifeq ($(GAME_TETRIS_CORE),y) + SUBDIRS += $(TOPDIR)/games/tetris +endif + +ifeq ($(GAME_SPACE_INVADERS),y) + SUBDIRS += $(TOPDIR)/games/space_invaders +endif + +ifeq ($(GAME_SNAKE),y) + SUBDIRS += $(TOPDIR)/games/snake +endif + +ifeq ($(ANIMATION_SNAKE),y) + ifneq ($(GAME_SNAKE),y) + SUBDIRS += $(TOPDIR)/games/snake + endif +endif + +ifeq ($(GAME_BREAKOUT),y) + SUBDIRS += $(TOPDIR)/games/breakout +endif + +ifeq ($(GAME_KART),y) + SUBDIRS += $(TOPDIR)/games/kart +endif + diff --git a/src/games/kart/Makefile b/src/games/kart/Makefile new file mode 100644 index 0000000..ab188d8 --- /dev/null +++ b/src/games/kart/Makefile @@ -0,0 +1,11 @@ +MAKETOPDIR = ../../.. + +TARGET = + +include $(MAKETOPDIR)/defaults.mk + +SRC = kart.c + +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/games/kart/kart.c b/src/games/kart/kart.c similarity index 100% rename from games/kart/kart.c rename to src/games/kart/kart.c diff --git a/games/kart/kart.h b/src/games/kart/kart.h similarity index 100% rename from games/kart/kart.h rename to src/games/kart/kart.h diff --git a/src/games/snake/Makefile b/src/games/snake/Makefile new file mode 100644 index 0000000..95e4037 --- /dev/null +++ b/src/games/snake/Makefile @@ -0,0 +1,11 @@ +MAKETOPDIR = ../../.. + +TARGET = + +include $(MAKETOPDIR)/defaults.mk + +SRC = snake_game.c + +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/games/snake/snake_game.c b/src/games/snake/snake_game.c similarity index 96% rename from games/snake/snake_game.c rename to src/games/snake/snake_game.c index 1182e1e..f89a445 100644 --- a/games/snake/snake_game.c +++ b/src/games/snake/snake_game.c @@ -1,471 +1,471 @@ -/** - * \defgroup Snake Snake, a casual game including a demo mode. - * - * @{ - */ - -/** - * @file snake_game.c - * @brief Implementation of the snake game. - * @author Peter Fuhrmann, Martin Ongsiek, Daniel Otte, Christian Kroll - */ - -#include -#include -#include "../../config.h" -#include "../../compat/pgmspace.h" -#include "../../pixel.h" -#include "../../random/prng.h" -#include "../../util.h" -#include "../../joystick/joystick.h" -#include "../../menu/menu.h" -#include "snake_game.h" - - -#if defined MENU_SUPPORT && defined GAME_SNAKE -// snake icon (MSB is leftmost pixel) -static const uint8_t icon[8] PROGMEM = - {0xff, 0x81, 0xbd, 0xa5, 0xa5, 0xad, 0xa1, 0xbf}; - -game_descriptor_t snake_game_descriptor __attribute__((section(".game_descriptors"))) = -{ - &snake_game, - icon, -}; -#endif - - -/** - * If defined, joystick controls are NOT as "seen" by the snake but absolute, - * that is, if pressing up, snake goes up, etc. - */ -#define SNAKE_NEWCONTROL - -#if !defined USNAKE_MAX_LENGTH || defined DOXYGEN - /** The maximum length of the snake. */ - #define USNAKE_MAX_LENGTH 64u -#endif - -#if !defined SNAKE_MAX_APPLES || defined DOXYGEN - /** The maximum number of apples lying on the playing field. */ - #define SNAKE_MAX_APPLES 10 -#endif - -#if !defined SNAKE_CYCLE_DELAY || defined DOXYGEN - /** Delay (in ms) between every state change. */ - #define SNAKE_CYCLE_DELAY 100 -#endif - -#if !defined SNAKE_TERMINATION_DELAY || defined DOXYGEN - /** Delay (in ms) between every disappearing pixel of a dying snake. */ - #define SNAKE_TERMINATION_DELAY 60 -#endif - -/** The color of the surrounding border. */ -#define SNAKE_COLOR_BORDER 3 -/** The color of the snake. */ -#define SNAKE_COLOR_PROTAGONIST 3 -/** The color of the apples. */ -#define SNAKE_COLOR_APPLE 3 - - -/** - * Directions of the snake. - */ -enum snake_dir_e -{ - SNAKE_DIR_UP, /**< Snake is heading up. */ - SNAKE_DIR_RIGHT,/**< Snake is heading right. */ - SNAKE_DIR_DOWN, /**< Snake is heading down. */ - SNAKE_DIR_LEFT, /**< Snake is heading left. */ - SNAKE_DIR_NONE /**< Helper value for a "resting" joystick. */ -}; -#ifdef NDEBUG - typedef uint8_t snake_dir_t; -#else - typedef enum snake_dir_e snake_dir_t; -#endif - -/** - * This structure represents the snake character itself. It keeps track of the - * snake's segments, its head and tail and the direction it is heading. - */ -typedef struct snake_protagonist_s -{ - pixel aSegments[USNAKE_MAX_LENGTH]; /**< All segments of the snake. */ - uint8_t nHeadIndex; /**< Index of the head segment. */ - uint8_t nTailIndex; /**< Index of the tail segment. */ - snake_dir_t dir; /**< Direction of the snake. */ -} snake_protagonist_t; - - -/** - * This structure keeps track of all apples which are on the playing field. - */ -typedef struct snake_apples_s -{ - pixel aApples[SNAKE_MAX_APPLES]; /**< Positions of all existing apples. */ - uint8_t nAppleCount; /**< Count of currently existing apples. */ -} snake_apples_t; - - -/** - * This function returns the next position which is calculated from a given - * (current) position and a direction. - * @param pxNext The position we're going to leave. - * @param dir The direction that we are heading. - * @return The next position according the given direction. - */ -static pixel snake_nextDirection(pixel const pxNext, - snake_dir_t const dir) -{ - assert(dir < 4); - static int8_t const nDelta[] = {0, -1, 0, 1, 0}; - return (pixel){pxNext.x + nDelta[dir], pxNext.y + nDelta[dir + 1]}; -} - - -/** - * This function draws a border around the playing field. - */ -static void snake_drawBorder(void) -{ -#if NUM_COLS == NUM_ROWS - for (uint8_t i = NUM_COLS; i--;) - { - setpixel((pixel){i, 0}, SNAKE_COLOR_BORDER); - setpixel((pixel){i, NUM_ROWS - 1}, SNAKE_COLOR_BORDER); - setpixel((pixel){0, i}, SNAKE_COLOR_BORDER); - setpixel((pixel){NUM_COLS -1, i}, SNAKE_COLOR_BORDER); - } -#else - for (uint8_t x = NUM_COLS; x--;) - { - setpixel((pixel){x, 0}, SNAKE_COLOR_BORDER); - setpixel((pixel){x, NUM_ROWS - 1}, SNAKE_COLOR_BORDER); - } - for (uint8_t y = NUM_ROWS; y--;) - { - setpixel((pixel){0, y}, SNAKE_COLOR_BORDER); - setpixel((pixel){NUM_COLS - 1, y}, SNAKE_COLOR_BORDER); - } -#endif -} - -#ifdef GAME_SNAKE -/** - * This function translates hardware port information into joystick directions. - * @return The current direction of the joystick. - * @see snake_dir_e - */ -static snake_dir_t snake_queryJoystick(void) -{ - snake_dir_t dirJoystick; - if (JOYISUP) - { - dirJoystick = SNAKE_DIR_UP; - } - else if (JOYISRIGHT) - { - dirJoystick = SNAKE_DIR_RIGHT; - } - else if (JOYISDOWN) - { - dirJoystick = SNAKE_DIR_DOWN; - } - else if (JOYISLEFT) - { - dirJoystick = SNAKE_DIR_LEFT; - } - else - { - dirJoystick = SNAKE_DIR_NONE; - } - - return dirJoystick; -} -#endif - -/** - * This function initializes the structure which represents the snake itself. - * @param pprotSnake The pointer the protagonist structure to be initialized. - */ -static void snake_initGameProtagonist(snake_protagonist_t *pprotSnake) -{ - pprotSnake->aSegments[0] = (pixel){NUM_COLS / 2, NUM_ROWS / 2}; - pprotSnake->aSegments[1] = (pixel){NUM_COLS / 2, NUM_ROWS / 2 - 1}; - pprotSnake->nTailIndex = 0; - pprotSnake->nHeadIndex = 1; - pprotSnake->dir = SNAKE_DIR_UP; -} - -#ifdef GAME_SNAKE -/** - * Determines the next direction of the snake depending on the joystick's input. - * @param pprotSnake A pointer to the structure of the protagonist. - * @param pdirLast Last joystick direction to recognize prolonged key presses. - */ -static void snake_userControl(snake_protagonist_t *pprotSnake, - snake_dir_t *pdirLast) -{ - snake_dir_t dirJoystick = snake_queryJoystick(); -#ifdef SNAKE_NEWCONTROL - if (dirJoystick != SNAKE_DIR_NONE) - { - // valid transitions can only be uneven - if ((pprotSnake->dir + dirJoystick) & 0x01) - { - pprotSnake->dir = dirJoystick; - } - } -#else - if ((dirJoystick ^ *pdirLast) && (dirJoystick != SNAKE_DIR_NONE)) - { - // only left or right movements are valid - if (dirJoystick & 0x01) - { - // rotate through directions (either clockwise or counterclockwise) - pprotSnake->dir = (pprotSnake->dir + - (dirJoystick == SNAKE_DIR_LEFT ? 3 : 1)) % 4u; - } - } - *pdirLast = dirJoystick; -#endif -} -#endif - - -#ifdef ANIMATION_SNAKE -/** - * This function approximates the next direction which may lead to an apple - * (with a particular probability). - * @param pprotSnake A pointer to the hungry protagonist. - * @param pApples A pointer to a bunch of apples. - */ -static void snake_autoRoute(snake_protagonist_t *pprotSnake, - snake_apples_t *pApples) -{ - pixel pxHead = pprotSnake->aSegments[pprotSnake->nHeadIndex]; - if (random8() < 80) - { - uint8_t nNextApple = 0; - if (pApples->nAppleCount) - { - uint8_t nMinDist = UINT8_MAX; - for (uint8_t i = 0; i < pApples->nAppleCount; ++i) - { - uint8_t nDistX; - if (pxHead.x > pApples->aApples[i].x) - { - nDistX = pxHead.x - pApples->aApples[i].x; - } - else - { - nDistX = pApples->aApples[i].x - pxHead.x; - } - - uint8_t nDistY; - if (pxHead.y > pApples->aApples[i].y) - { - nDistY = pxHead.y - pApples->aApples[i].y; - } - else - { - nDistY = pApples->aApples[i].y - pxHead.y; - } - - if ((nDistX + nDistY) < nMinDist) - { - nMinDist = nDistX + nDistY; - nNextApple = i; - } - } - if (pprotSnake->dir ^ 0x01) // vertical direction? - { - pprotSnake->dir = pApples->aApples[nNextApple].x > pxHead.x ? - SNAKE_DIR_LEFT : SNAKE_DIR_RIGHT; - } - else - { - pprotSnake->dir = pApples->aApples[nNextApple].y > pxHead.y ? - SNAKE_DIR_DOWN : SNAKE_DIR_UP; - } - } - } - - for (uint8_t i = 0; i < 4; ++i) - { - pixel pxTest = snake_nextDirection(pxHead, pprotSnake->dir); - if (get_pixel(pxTest)) - { - for (uint8_t j = 0; j < pApples->nAppleCount; ++j) - { - if ((pxTest.x == pApples->aApples[j].x) && - (pxTest.y == pApples->aApples[j].y)) - { - return; - } - } - pprotSnake->dir = (pprotSnake->dir + 1u) % 4u; - } - else - { - break; - } - } -} -#endif - - -/** - * Small animation that lets the dying snake disappear piece by piece. - * @param pprotSnake A pointer to the dying snake. - */ -static void snake_eliminateProtagonist(snake_protagonist_t *pprotSnake) -{ - while (pprotSnake->nTailIndex != pprotSnake->nHeadIndex) - { - clearpixel(pprotSnake->aSegments[pprotSnake->nTailIndex++]); - pprotSnake->nTailIndex %= USNAKE_MAX_LENGTH; - wait(SNAKE_TERMINATION_DELAY); - } -} - - -/** - * Initializes the structure that keeps track of all currently existing apples. - * @param pApples Pointer to the set of apples in question. - */ -static void snake_initApples(snake_apples_t *pApples) -{ - pApples->nAppleCount = 0; -} - - -/** - * Checks for an apple at a given position and removes it if there is one. - * @param pApples The set of apples which are lying on the playing field. - * @param pxHead The position to be tested. - * @return 0 if no apples were found, 1 otherwise - */ -static uint8_t snake_checkForApple(snake_apples_t *pApples, pixel pxHead) -{ - for (uint8_t i = pApples->nAppleCount; i--;) - { - if ((pxHead.x == pApples->aApples[i].x) && - (pxHead.y == pApples->aApples[i].y)) - { - for (; i < pApples->nAppleCount; ++i) - { - pApples->aApples[i] = pApples->aApples[i + 1]; - } - --pApples->nAppleCount; - return 1; - } - } - return 0; -} - - -/** - * Creates some new apples from time to time. - * @param pApples Pointer to a set of apples. - */ -static void snake_spawnApples(snake_apples_t *pApples) -{ - if ((pApples->nAppleCount < SNAKE_MAX_APPLES) && (random8() < 10)) - { - pixel pxApple = (pixel){(random8() % (NUM_COLS-2)) + 1, - (random8() % (NUM_ROWS - 2)) + 1}; - if (!get_pixel(pxApple)) - { - pApples->aApples[pApples->nAppleCount++] = pxApple; - } - } -} - - -/** - * The main loop (plus initialization) that both drives the game and the - * demo mode. - * @param bDemoMode 0 indicates game mode, 1 indicates demo mode - */ -void snake_engine(uint8_t bDemoMode) -{ - // init - snake_protagonist_t protSnake; - snake_initGameProtagonist(&protSnake); - snake_apples_t apples; - snake_initApples(&apples); - snake_dir_t dirLast = SNAKE_DIR_NONE; - - // init screen - clear_screen(0); - snake_drawBorder(); - - for (uint8_t nAppleColor = 0; 1; nAppleColor ^= SNAKE_COLOR_APPLE) - { - // determine new direction -#if defined ANIMATION_SNAKE && defined GAME_SNAKE - if (bDemoMode) - { - snake_autoRoute(&protSnake, &apples); - } - else - { - snake_userControl(&protSnake, &dirLast); - } -#elif defined ANIMATION_SNAKE - snake_autoRoute(&protSnake, &apples); -#else - snake_userControl(&protSnake, &dirLast); -#endif - - // actually move head - pixel pxOldHead = protSnake.aSegments[protSnake.nHeadIndex]; - protSnake.nHeadIndex = (protSnake.nHeadIndex + 1u) % USNAKE_MAX_LENGTH; - protSnake.aSegments[protSnake.nHeadIndex] = - snake_nextDirection(pxOldHead, protSnake.dir); - - // look if we have found an apple - if (!snake_checkForApple(&apples, - protSnake.aSegments[protSnake.nHeadIndex])) - { - // quit game if we hit something which is not an apple - if (get_pixel(protSnake.aSegments[protSnake.nHeadIndex])) - { - snake_eliminateProtagonist(&protSnake); - return; - } - - // remove last segment - clearpixel(protSnake.aSegments[protSnake.nTailIndex]) - protSnake.nTailIndex = - (protSnake.nTailIndex + 1u) % USNAKE_MAX_LENGTH; - - // new apples - snake_spawnApples(&apples); - } - // draw new head - setpixel(protSnake.aSegments[protSnake.nHeadIndex], - SNAKE_COLOR_PROTAGONIST); - - // draw apples - for (uint8_t i = apples.nAppleCount; i--;) - { - setpixel(apples.aApples[i], nAppleColor); - } - - wait(SNAKE_CYCLE_DELAY); - } -} - -/** - * Snake in game mode. - */ -void snake_game(void) -{ - snake_engine(0); -} - -/*@}*/ +/** + * \defgroup Snake Snake, a casual game including a demo mode. + * + * @{ + */ + +/** + * @file snake_game.c + * @brief Implementation of the snake game. + * @author Peter Fuhrmann, Martin Ongsiek, Daniel Otte, Christian Kroll + */ + +#include +#include +#include "../../config.h" +#include "../../compat/pgmspace.h" +#include "../../pixel.h" +#include "../../random/prng.h" +#include "../../util.h" +#include "../../joystick/joystick.h" +#include "../../menu/menu.h" +#include "snake_game.h" + + +#if defined MENU_SUPPORT && defined GAME_SNAKE +// snake icon (MSB is leftmost pixel) +static const uint8_t icon[8] PROGMEM = + {0xff, 0x81, 0xbd, 0xa5, 0xa5, 0xad, 0xa1, 0xbf}; + +game_descriptor_t snake_game_descriptor __attribute__((section(".game_descriptors"))) = +{ + &snake_game, + icon, +}; +#endif + + +/** + * If defined, joystick controls are NOT as "seen" by the snake but absolute, + * that is, if pressing up, snake goes up, etc. + */ +#define SNAKE_NEWCONTROL + +#if !defined USNAKE_MAX_LENGTH || defined DOXYGEN + /** The maximum length of the snake. */ + #define USNAKE_MAX_LENGTH 64u +#endif + +#if !defined SNAKE_MAX_APPLES || defined DOXYGEN + /** The maximum number of apples lying on the playing field. */ + #define SNAKE_MAX_APPLES 10 +#endif + +#if !defined SNAKE_CYCLE_DELAY || defined DOXYGEN + /** Delay (in ms) between every state change. */ + #define SNAKE_CYCLE_DELAY 100 +#endif + +#if !defined SNAKE_TERMINATION_DELAY || defined DOXYGEN + /** Delay (in ms) between every disappearing pixel of a dying snake. */ + #define SNAKE_TERMINATION_DELAY 60 +#endif + +/** The color of the surrounding border. */ +#define SNAKE_COLOR_BORDER 3 +/** The color of the snake. */ +#define SNAKE_COLOR_PROTAGONIST 3 +/** The color of the apples. */ +#define SNAKE_COLOR_APPLE 3 + + +/** + * Directions of the snake. + */ +enum snake_dir_e +{ + SNAKE_DIR_UP, /**< Snake is heading up. */ + SNAKE_DIR_RIGHT,/**< Snake is heading right. */ + SNAKE_DIR_DOWN, /**< Snake is heading down. */ + SNAKE_DIR_LEFT, /**< Snake is heading left. */ + SNAKE_DIR_NONE /**< Helper value for a "resting" joystick. */ +}; +#ifdef NDEBUG + typedef uint8_t snake_dir_t; +#else + typedef enum snake_dir_e snake_dir_t; +#endif + +/** + * This structure represents the snake character itself. It keeps track of the + * snake's segments, its head and tail and the direction it is heading. + */ +typedef struct snake_protagonist_s +{ + pixel aSegments[USNAKE_MAX_LENGTH]; /**< All segments of the snake. */ + uint8_t nHeadIndex; /**< Index of the head segment. */ + uint8_t nTailIndex; /**< Index of the tail segment. */ + snake_dir_t dir; /**< Direction of the snake. */ +} snake_protagonist_t; + + +/** + * This structure keeps track of all apples which are on the playing field. + */ +typedef struct snake_apples_s +{ + pixel aApples[SNAKE_MAX_APPLES]; /**< Positions of all existing apples. */ + uint8_t nAppleCount; /**< Count of currently existing apples. */ +} snake_apples_t; + + +/** + * This function returns the next position which is calculated from a given + * (current) position and a direction. + * @param pxNext The position we're going to leave. + * @param dir The direction that we are heading. + * @return The next position according the given direction. + */ +static pixel snake_nextDirection(pixel const pxNext, + snake_dir_t const dir) +{ + assert(dir < 4); + static int8_t const nDelta[] = {0, -1, 0, 1, 0}; + return (pixel){pxNext.x + nDelta[dir], pxNext.y + nDelta[dir + 1]}; +} + + +/** + * This function draws a border around the playing field. + */ +static void snake_drawBorder(void) +{ +#if NUM_COLS == NUM_ROWS + for (uint8_t i = NUM_COLS; i--;) + { + setpixel((pixel){i, 0}, SNAKE_COLOR_BORDER); + setpixel((pixel){i, NUM_ROWS - 1}, SNAKE_COLOR_BORDER); + setpixel((pixel){0, i}, SNAKE_COLOR_BORDER); + setpixel((pixel){NUM_COLS -1, i}, SNAKE_COLOR_BORDER); + } +#else + for (uint8_t x = NUM_COLS; x--;) + { + setpixel((pixel){x, 0}, SNAKE_COLOR_BORDER); + setpixel((pixel){x, NUM_ROWS - 1}, SNAKE_COLOR_BORDER); + } + for (uint8_t y = NUM_ROWS; y--;) + { + setpixel((pixel){0, y}, SNAKE_COLOR_BORDER); + setpixel((pixel){NUM_COLS - 1, y}, SNAKE_COLOR_BORDER); + } +#endif +} + +#ifdef GAME_SNAKE +/** + * This function translates hardware port information into joystick directions. + * @return The current direction of the joystick. + * @see snake_dir_e + */ +static snake_dir_t snake_queryJoystick(void) +{ + snake_dir_t dirJoystick; + if (JOYISUP) + { + dirJoystick = SNAKE_DIR_UP; + } + else if (JOYISRIGHT) + { + dirJoystick = SNAKE_DIR_RIGHT; + } + else if (JOYISDOWN) + { + dirJoystick = SNAKE_DIR_DOWN; + } + else if (JOYISLEFT) + { + dirJoystick = SNAKE_DIR_LEFT; + } + else + { + dirJoystick = SNAKE_DIR_NONE; + } + + return dirJoystick; +} +#endif + +/** + * This function initializes the structure which represents the snake itself. + * @param pprotSnake The pointer the protagonist structure to be initialized. + */ +static void snake_initGameProtagonist(snake_protagonist_t *pprotSnake) +{ + pprotSnake->aSegments[0] = (pixel){NUM_COLS / 2, NUM_ROWS / 2}; + pprotSnake->aSegments[1] = (pixel){NUM_COLS / 2, NUM_ROWS / 2 - 1}; + pprotSnake->nTailIndex = 0; + pprotSnake->nHeadIndex = 1; + pprotSnake->dir = SNAKE_DIR_UP; +} + +#ifdef GAME_SNAKE +/** + * Determines the next direction of the snake depending on the joystick's input. + * @param pprotSnake A pointer to the structure of the protagonist. + * @param pdirLast Last joystick direction to recognize prolonged key presses. + */ +static void snake_userControl(snake_protagonist_t *pprotSnake, + snake_dir_t *pdirLast) +{ + snake_dir_t dirJoystick = snake_queryJoystick(); +#ifdef SNAKE_NEWCONTROL + if (dirJoystick != SNAKE_DIR_NONE) + { + // valid transitions can only be uneven + if ((pprotSnake->dir + dirJoystick) & 0x01) + { + pprotSnake->dir = dirJoystick; + } + } +#else + if ((dirJoystick ^ *pdirLast) && (dirJoystick != SNAKE_DIR_NONE)) + { + // only left or right movements are valid + if (dirJoystick & 0x01) + { + // rotate through directions (either clockwise or counterclockwise) + pprotSnake->dir = (pprotSnake->dir + + (dirJoystick == SNAKE_DIR_LEFT ? 3 : 1)) % 4u; + } + } + *pdirLast = dirJoystick; +#endif +} +#endif + + +#ifdef ANIMATION_SNAKE +/** + * This function approximates the next direction which may lead to an apple + * (with a particular probability). + * @param pprotSnake A pointer to the hungry protagonist. + * @param pApples A pointer to a bunch of apples. + */ +static void snake_autoRoute(snake_protagonist_t *pprotSnake, + snake_apples_t *pApples) +{ + pixel pxHead = pprotSnake->aSegments[pprotSnake->nHeadIndex]; + if (random8() < 80) + { + uint8_t nNextApple = 0; + if (pApples->nAppleCount) + { + uint8_t nMinDist = UINT8_MAX; + for (uint8_t i = 0; i < pApples->nAppleCount; ++i) + { + uint8_t nDistX; + if (pxHead.x > pApples->aApples[i].x) + { + nDistX = pxHead.x - pApples->aApples[i].x; + } + else + { + nDistX = pApples->aApples[i].x - pxHead.x; + } + + uint8_t nDistY; + if (pxHead.y > pApples->aApples[i].y) + { + nDistY = pxHead.y - pApples->aApples[i].y; + } + else + { + nDistY = pApples->aApples[i].y - pxHead.y; + } + + if ((nDistX + nDistY) < nMinDist) + { + nMinDist = nDistX + nDistY; + nNextApple = i; + } + } + if (pprotSnake->dir ^ 0x01) // vertical direction? + { + pprotSnake->dir = pApples->aApples[nNextApple].x > pxHead.x ? + SNAKE_DIR_LEFT : SNAKE_DIR_RIGHT; + } + else + { + pprotSnake->dir = pApples->aApples[nNextApple].y > pxHead.y ? + SNAKE_DIR_DOWN : SNAKE_DIR_UP; + } + } + } + + for (uint8_t i = 0; i < 4; ++i) + { + pixel pxTest = snake_nextDirection(pxHead, pprotSnake->dir); + if (get_pixel(pxTest)) + { + for (uint8_t j = 0; j < pApples->nAppleCount; ++j) + { + if ((pxTest.x == pApples->aApples[j].x) && + (pxTest.y == pApples->aApples[j].y)) + { + return; + } + } + pprotSnake->dir = (pprotSnake->dir + 1u) % 4u; + } + else + { + break; + } + } +} +#endif + + +/** + * Small animation that lets the dying snake disappear piece by piece. + * @param pprotSnake A pointer to the dying snake. + */ +static void snake_eliminateProtagonist(snake_protagonist_t *pprotSnake) +{ + while (pprotSnake->nTailIndex != pprotSnake->nHeadIndex) + { + clearpixel(pprotSnake->aSegments[pprotSnake->nTailIndex++]); + pprotSnake->nTailIndex %= USNAKE_MAX_LENGTH; + wait(SNAKE_TERMINATION_DELAY); + } +} + + +/** + * Initializes the structure that keeps track of all currently existing apples. + * @param pApples Pointer to the set of apples in question. + */ +static void snake_initApples(snake_apples_t *pApples) +{ + pApples->nAppleCount = 0; +} + + +/** + * Checks for an apple at a given position and removes it if there is one. + * @param pApples The set of apples which are lying on the playing field. + * @param pxHead The position to be tested. + * @return 0 if no apples were found, 1 otherwise + */ +static uint8_t snake_checkForApple(snake_apples_t *pApples, pixel pxHead) +{ + for (uint8_t i = pApples->nAppleCount; i--;) + { + if ((pxHead.x == pApples->aApples[i].x) && + (pxHead.y == pApples->aApples[i].y)) + { + for (; i < pApples->nAppleCount; ++i) + { + pApples->aApples[i] = pApples->aApples[i + 1]; + } + --pApples->nAppleCount; + return 1; + } + } + return 0; +} + + +/** + * Creates some new apples from time to time. + * @param pApples Pointer to a set of apples. + */ +static void snake_spawnApples(snake_apples_t *pApples) +{ + if ((pApples->nAppleCount < SNAKE_MAX_APPLES) && (random8() < 10)) + { + pixel pxApple = (pixel){(random8() % (NUM_COLS-2)) + 1, + (random8() % (NUM_ROWS - 2)) + 1}; + if (!get_pixel(pxApple)) + { + pApples->aApples[pApples->nAppleCount++] = pxApple; + } + } +} + + +/** + * The main loop (plus initialization) that both drives the game and the + * demo mode. + * @param bDemoMode 0 indicates game mode, 1 indicates demo mode + */ +void snake_engine(uint8_t bDemoMode) +{ + // init + snake_protagonist_t protSnake; + snake_initGameProtagonist(&protSnake); + snake_apples_t apples; + snake_initApples(&apples); + snake_dir_t dirLast = SNAKE_DIR_NONE; + + // init screen + clear_screen(0); + snake_drawBorder(); + + for (uint8_t nAppleColor = 0; 1; nAppleColor ^= SNAKE_COLOR_APPLE) + { + // determine new direction +#if defined ANIMATION_SNAKE && defined GAME_SNAKE + if (bDemoMode) + { + snake_autoRoute(&protSnake, &apples); + } + else + { + snake_userControl(&protSnake, &dirLast); + } +#elif defined ANIMATION_SNAKE + snake_autoRoute(&protSnake, &apples); +#else + snake_userControl(&protSnake, &dirLast); +#endif + + // actually move head + pixel pxOldHead = protSnake.aSegments[protSnake.nHeadIndex]; + protSnake.nHeadIndex = (protSnake.nHeadIndex + 1u) % USNAKE_MAX_LENGTH; + protSnake.aSegments[protSnake.nHeadIndex] = + snake_nextDirection(pxOldHead, protSnake.dir); + + // look if we have found an apple + if (!snake_checkForApple(&apples, + protSnake.aSegments[protSnake.nHeadIndex])) + { + // quit game if we hit something which is not an apple + if (get_pixel(protSnake.aSegments[protSnake.nHeadIndex])) + { + snake_eliminateProtagonist(&protSnake); + return; + } + + // remove last segment + clearpixel(protSnake.aSegments[protSnake.nTailIndex]) + protSnake.nTailIndex = + (protSnake.nTailIndex + 1u) % USNAKE_MAX_LENGTH; + + // new apples + snake_spawnApples(&apples); + } + // draw new head + setpixel(protSnake.aSegments[protSnake.nHeadIndex], + SNAKE_COLOR_PROTAGONIST); + + // draw apples + for (uint8_t i = apples.nAppleCount; i--;) + { + setpixel(apples.aApples[i], nAppleColor); + } + + wait(SNAKE_CYCLE_DELAY); + } +} + +/** + * Snake in game mode. + */ +void snake_game(void) +{ + snake_engine(0); +} + +/*@}*/ diff --git a/games/snake/snake_game.h b/src/games/snake/snake_game.h similarity index 100% rename from games/snake/snake_game.h rename to src/games/snake/snake_game.h diff --git a/src/games/space_invaders/Makefile b/src/games/space_invaders/Makefile new file mode 100644 index 0000000..0680ce7 --- /dev/null +++ b/src/games/space_invaders/Makefile @@ -0,0 +1,11 @@ +MAKETOPDIR = ../../.. + +TARGET = + +include $(MAKETOPDIR)/defaults.mk + +SRC = invader_init.c invader_draw.c invader_proc.c invaders2.c + +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/games/space_invaders/invader_draw.c b/src/games/space_invaders/invader_draw.c similarity index 100% rename from games/space_invaders/invader_draw.c rename to src/games/space_invaders/invader_draw.c diff --git a/games/space_invaders/invader_init.c b/src/games/space_invaders/invader_init.c similarity index 100% rename from games/space_invaders/invader_init.c rename to src/games/space_invaders/invader_init.c diff --git a/games/space_invaders/invader_proc.c b/src/games/space_invaders/invader_proc.c similarity index 100% rename from games/space_invaders/invader_proc.c rename to src/games/space_invaders/invader_proc.c diff --git a/games/space_invaders/invaders2.c b/src/games/space_invaders/invaders2.c similarity index 100% rename from games/space_invaders/invaders2.c rename to src/games/space_invaders/invaders2.c diff --git a/games/space_invaders/invaders2.h b/src/games/space_invaders/invaders2.h similarity index 100% rename from games/space_invaders/invaders2.h rename to src/games/space_invaders/invaders2.h diff --git a/games/tetris/COPYING b/src/games/tetris/COPYING similarity index 100% rename from games/tetris/COPYING rename to src/games/tetris/COPYING diff --git a/games/tetris/LICENSE b/src/games/tetris/LICENSE similarity index 100% rename from games/tetris/LICENSE rename to src/games/tetris/LICENSE diff --git a/games/tetris/Makefile b/src/games/tetris/Makefile similarity index 71% rename from games/tetris/Makefile rename to src/games/tetris/Makefile index 78ca3bd..3d737f2 100644 --- a/games/tetris/Makefile +++ b/src/games/tetris/Makefile @@ -1,7 +1,8 @@ -TARGET = -TOPDIR = ../.. +MAKETOPDIR = ../../.. -include $(TOPDIR)/defaults.mk +TARGET = + +include $(MAKETOPDIR)/defaults.mk SRC = tetris_main.c piece.c bucket.c view.c input.c highscore.c @@ -20,4 +21,6 @@ ifeq ($(GAME_TETRIS_FP),y) SRC += variant_fp.c endif -include $(TOPDIR)/rules.mk +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/games/tetris/bearing.h b/src/games/tetris/bearing.h similarity index 100% rename from games/tetris/bearing.h rename to src/games/tetris/bearing.h diff --git a/games/tetris/bucket.c b/src/games/tetris/bucket.c similarity index 100% rename from games/tetris/bucket.c rename to src/games/tetris/bucket.c diff --git a/games/tetris/bucket.h b/src/games/tetris/bucket.h similarity index 100% rename from games/tetris/bucket.h rename to src/games/tetris/bucket.h diff --git a/games/tetris/highscore.c b/src/games/tetris/highscore.c similarity index 100% rename from games/tetris/highscore.c rename to src/games/tetris/highscore.c diff --git a/games/tetris/highscore.h b/src/games/tetris/highscore.h similarity index 100% rename from games/tetris/highscore.h rename to src/games/tetris/highscore.h diff --git a/games/tetris/input.c b/src/games/tetris/input.c similarity index 100% rename from games/tetris/input.c rename to src/games/tetris/input.c diff --git a/games/tetris/input.h b/src/games/tetris/input.h similarity index 100% rename from games/tetris/input.h rename to src/games/tetris/input.h diff --git a/games/tetris/piece.c b/src/games/tetris/piece.c similarity index 100% rename from games/tetris/piece.c rename to src/games/tetris/piece.c diff --git a/games/tetris/piece.h b/src/games/tetris/piece.h similarity index 100% rename from games/tetris/piece.h rename to src/games/tetris/piece.h diff --git a/games/tetris/tetris_main.c b/src/games/tetris/tetris_main.c similarity index 100% rename from games/tetris/tetris_main.c rename to src/games/tetris/tetris_main.c diff --git a/games/tetris/tetris_main.h b/src/games/tetris/tetris_main.h similarity index 100% rename from games/tetris/tetris_main.h rename to src/games/tetris/tetris_main.h diff --git a/games/tetris/variant_bastet.c b/src/games/tetris/variant_bastet.c similarity index 100% rename from games/tetris/variant_bastet.c rename to src/games/tetris/variant_bastet.c diff --git a/games/tetris/variant_bastet.h b/src/games/tetris/variant_bastet.h similarity index 100% rename from games/tetris/variant_bastet.h rename to src/games/tetris/variant_bastet.h diff --git a/games/tetris/variant_fp.c b/src/games/tetris/variant_fp.c similarity index 100% rename from games/tetris/variant_fp.c rename to src/games/tetris/variant_fp.c diff --git a/games/tetris/variant_fp.h b/src/games/tetris/variant_fp.h similarity index 100% rename from games/tetris/variant_fp.h rename to src/games/tetris/variant_fp.h diff --git a/games/tetris/variant_std.c b/src/games/tetris/variant_std.c similarity index 100% rename from games/tetris/variant_std.c rename to src/games/tetris/variant_std.c diff --git a/games/tetris/variant_std.h b/src/games/tetris/variant_std.h similarity index 100% rename from games/tetris/variant_std.h rename to src/games/tetris/variant_std.h diff --git a/games/tetris/variants.h b/src/games/tetris/variants.h similarity index 100% rename from games/tetris/variants.h rename to src/games/tetris/variants.h diff --git a/games/tetris/view.c b/src/games/tetris/view.c similarity index 100% rename from games/tetris/view.c rename to src/games/tetris/view.c diff --git a/games/tetris/view.h b/src/games/tetris/view.h similarity index 100% rename from games/tetris/view.h rename to src/games/tetris/view.h diff --git a/ioport.h b/src/ioport.h similarity index 95% rename from ioport.h rename to src/ioport.h index 46f4ed5..2de4911 100644 --- a/ioport.h +++ b/src/ioport.h @@ -1,40 +1,40 @@ - -// Makros for simplified single pin io access. - -#define PORT_(port) PORT ## port -#define DDR_(port) DDR ## port -#define PIN_(port) PIN ## port - -#define PORT(port) PORT_(port) -#define DDRR(port) DDR_(port) -#define PINN(port) PIN_(port) - -#define SET_DDR(p) DDRR(p##_PORT) |= (1< -dy) + { + error -= dy; + p1.x += sx; + } + if (error2 < dx) + { + error += dx; + p1.y += sy; + } + } +} diff --git a/pixel.h b/src/pixel.h similarity index 82% rename from pixel.h rename to src/pixel.h index a9204f4..252e4b5 100644 --- a/pixel.h +++ b/src/pixel.h @@ -42,6 +42,15 @@ typedef struct cursor{ pixelmode_t mode; } cursor_t; + +#if NUM_ROWS < 64 && NUM_COLS < 64 + /** use 8 bit operands where feasible */ + typedef signed char operand_t; +#else + /** use 16 bit operands if either width or height are >= 64 */ + typedef int operand_t; +#endif + /**************************************************************************** * Pixel routines */ @@ -79,4 +88,8 @@ static inline void set_cursor(cursor_t* cur, pixel p){ setpixel(p, cur->mode ? 3 : 0); } +void line(pixel p1, + pixel const p2, + unsigned char const color); + #endif // PIXEL_H diff --git a/random/Makefile b/src/random/Makefile similarity index 60% rename from random/Makefile rename to src/random/Makefile index ff5859d..725498e 100644 --- a/random/Makefile +++ b/src/random/Makefile @@ -1,7 +1,8 @@ -TARGET = objects_avr -TOPDIR = .. +MAKETOPDIR = ../.. -include $(TOPDIR)/defaults.mk +TARGET = objects_avr + +include $(MAKETOPDIR)/defaults.mk #for AVR SRC = prng.c persistentCounter.c @@ -10,7 +11,6 @@ ASRC = noekeon_asm.S memxor.S #for simulator SRC_SIM = prng.c persistentCounter.c noekeon.c memxor_c.c +include $(MAKETOPDIR)/rules.mk - - -include $(TOPDIR)/rules.mk +include $(MAKETOPDIR)/depend.mk diff --git a/random/memxor.S b/src/random/memxor.S similarity index 100% rename from random/memxor.S rename to src/random/memxor.S diff --git a/random/memxor.h b/src/random/memxor.h similarity index 100% rename from random/memxor.h rename to src/random/memxor.h diff --git a/random/memxor_c.c b/src/random/memxor_c.c similarity index 100% rename from random/memxor_c.c rename to src/random/memxor_c.c diff --git a/random/noekeon.c b/src/random/noekeon.c similarity index 100% rename from random/noekeon.c rename to src/random/noekeon.c diff --git a/random/noekeon.h b/src/random/noekeon.h similarity index 100% rename from random/noekeon.h rename to src/random/noekeon.h diff --git a/random/noekeon_asm.S b/src/random/noekeon_asm.S similarity index 100% rename from random/noekeon_asm.S rename to src/random/noekeon_asm.S diff --git a/random/persistentCounter.c b/src/random/persistentCounter.c similarity index 100% rename from random/persistentCounter.c rename to src/random/persistentCounter.c diff --git a/random/persistentCounter.h b/src/random/persistentCounter.h similarity index 100% rename from random/persistentCounter.h rename to src/random/persistentCounter.h diff --git a/random/prng.c b/src/random/prng.c similarity index 100% rename from random/prng.c rename to src/random/prng.c diff --git a/random/prng.h b/src/random/prng.h similarity index 100% rename from random/prng.h rename to src/random/prng.h diff --git a/src/rfm12/Makefile b/src/rfm12/Makefile new file mode 100644 index 0000000..89dccca --- /dev/null +++ b/src/rfm12/Makefile @@ -0,0 +1,11 @@ +MAKETOPDIR = ../.. + +TARGET = objects + +include $(MAKETOPDIR)/defaults.mk + +SRC = rfm12.c borg_rfm12.c + +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/rfm12/borg_rfm12.c b/src/rfm12/borg_rfm12.c similarity index 94% rename from rfm12/borg_rfm12.c rename to src/rfm12/borg_rfm12.c index 3f6e0fc..17ba1ab 100644 --- a/rfm12/borg_rfm12.c +++ b/src/rfm12/borg_rfm12.c @@ -1,36 +1,36 @@ - -#include -#include - -#include "rfm12.h" - -volatile uint8_t rfm12_joystick_val; - -void borg_rfm12_tick(){ - if (rfm12_rx_status() == STATUS_COMPLETE) - { - - //uart_putstr ("new packet:\r\n"); - - uint8_t * bufp = rfm12_rx_buffer(); - - // dump buffer contents to uart - if(rfm12_rx_len() >= 1){ - //-> F2 F1 RT LF DN UP - - rfm12_joystick_val = *bufp; - } - - // tell the implementation that the buffer - // can be reused for the next data. - rfm12_rx_clear(); - } - - rfm12_tick(); - -} - -void borg_rfm12_init(){ - _delay_ms(200);//the rfm12 seems to need this - rfm12_init(); -} + +#include +#include + +#include "rfm12.h" + +volatile uint8_t rfm12_joystick_val; + +void borg_rfm12_tick(){ + if (rfm12_rx_status() == STATUS_COMPLETE) + { + + //uart_putstr ("new packet:\r\n"); + + uint8_t * bufp = rfm12_rx_buffer(); + + // dump buffer contents to uart + if(rfm12_rx_len() >= 1){ + //-> F2 F1 RT LF DN UP + + rfm12_joystick_val = *bufp; + } + + // tell the implementation that the buffer + // can be reused for the next data. + rfm12_rx_clear(); + } + + rfm12_tick(); + +} + +void borg_rfm12_init(){ + _delay_ms(200);//the rfm12 seems to need this + rfm12_init(); +} diff --git a/rfm12/borg_rfm12.h b/src/rfm12/borg_rfm12.h similarity index 94% rename from rfm12/borg_rfm12.h rename to src/rfm12/borg_rfm12.h index b379758..d26d8e9 100644 --- a/rfm12/borg_rfm12.h +++ b/src/rfm12/borg_rfm12.h @@ -1,6 +1,6 @@ - -void borg_rfm12_init(); -void borg_rfm12_tick(); - -extern volatile uint8_t rfm12_joystick_val; - + +void borg_rfm12_init(); +void borg_rfm12_tick(); + +extern volatile uint8_t rfm12_joystick_val; + diff --git a/rfm12/config.in b/src/rfm12/config.in similarity index 100% rename from rfm12/config.in rename to src/rfm12/config.in diff --git a/src/rfm12/rfm12.c b/src/rfm12/rfm12.c new file mode 100644 index 0000000..7ca2b3e --- /dev/null +++ b/src/rfm12/rfm12.c @@ -0,0 +1,4 @@ + +#include "rfm12_config.h" +#include "rfm12_lib/src/rfm12.c" + diff --git a/src/rfm12/rfm12.h b/src/rfm12/rfm12.h new file mode 100644 index 0000000..2767cfd --- /dev/null +++ b/src/rfm12/rfm12.h @@ -0,0 +1,4 @@ + +#include "rfm12_config.h" +#include "rfm12_lib/src/rfm12.h" + diff --git a/rfm12/rfm12_config.h b/src/rfm12/rfm12_config.h similarity index 94% rename from rfm12/rfm12_config.h rename to src/rfm12/rfm12_config.h index f5d4bd6..3f160b5 100644 --- a/rfm12/rfm12_config.h +++ b/src/rfm12/rfm12_config.h @@ -49,6 +49,8 @@ #include "../config.h" #include "../makros.h" +#include + //Pin that the RFM12's slave select is connected to //#define DDR_SS DDRB //#define PORT_SS PORTB @@ -124,13 +126,23 @@ #define RFM12_INT_VECT (INT0_vect) //the interrupt mask register -#define RFM12_INT_MSK GIMSK +#ifdef EIMSK + #define RFM12_INT_MSK EIMSK +#elif defined(GIMSK) + #define RFM12_INT_MSK GIMSK +#else + #define RFM12_INT_MSK GICR +#endif //the interrupt bit in the mask register #define RFM12_INT_BIT (INT0) //the interrupt flag register -#define RFM12_INT_FLAG GIFR +#ifdef EIFR + #define RFM12_INT_FLAG EIFR +#else + #define RFM12_INT_FLAG GIFR +#endif //the interrupt bit in the flag register #define RFM12_FLAG_BIT (INTF0) @@ -160,6 +172,3 @@ */ #define RFM12_UART_DEBUG 0 - - - diff --git a/src/rfm12/rfm12_lib b/src/rfm12/rfm12_lib new file mode 160000 index 0000000..e49ecec --- /dev/null +++ b/src/rfm12/rfm12_lib @@ -0,0 +1 @@ +Subproject commit e49ecece7baf2faa48ed2f6c659228b4d77c0c66 diff --git a/src/scrolltext/Makefile b/src/scrolltext/Makefile new file mode 100644 index 0000000..40ac8ce --- /dev/null +++ b/src/scrolltext/Makefile @@ -0,0 +1,12 @@ +MAKETOPDIR = ../.. + +TARGET = objects + +include $(MAKETOPDIR)/defaults.mk + +SRC = scrolltext3.c +SRC += $(shell echo $(SCROLLTEXT_FONT) | tr A-Z a-z).c + +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/scrolltext/config.in b/src/scrolltext/config.in similarity index 100% rename from scrolltext/config.in rename to src/scrolltext/config.in diff --git a/scrolltext/font.h b/src/scrolltext/font.h similarity index 100% rename from scrolltext/font.h rename to src/scrolltext/font.h diff --git a/scrolltext/font_arial8.c b/src/scrolltext/font_arial8.c similarity index 100% rename from scrolltext/font_arial8.c rename to src/scrolltext/font_arial8.c diff --git a/scrolltext/font_arial8.h b/src/scrolltext/font_arial8.h similarity index 100% rename from scrolltext/font_arial8.h rename to src/scrolltext/font_arial8.h diff --git a/scrolltext/font_c64.c b/src/scrolltext/font_c64.c similarity index 100% rename from scrolltext/font_c64.c rename to src/scrolltext/font_c64.c diff --git a/scrolltext/font_c64.h b/src/scrolltext/font_c64.h similarity index 100% rename from scrolltext/font_c64.h rename to src/scrolltext/font_c64.h diff --git a/scrolltext/font_small6.c b/src/scrolltext/font_small6.c similarity index 98% rename from scrolltext/font_small6.c rename to src/scrolltext/font_small6.c index 7a22f13..da0ebce 100644 --- a/scrolltext/font_small6.c +++ b/src/scrolltext/font_small6.c @@ -1,439 +1,439 @@ -#include "font.h" - -unsigned int PROGMEM fontIndex_small6[] = { - 0, /* */ - 1, /* ! */ - 2, /* " */ - 5, /* # */ - 10, /* $ */ - 13, /* % */ - 17, /* & */ - 21, /* ' */ - 22, /* ( */ - 24, /* ) */ - 26, /* * */ - 28, /* + */ - 31, /* , */ - 32, /* - */ - 34, /* . */ - 35, /* / */ - 37, /* 0 */ - 41, /* 1 */ - 43, /* 2 */ - 47, /* 3 */ - 51, /* 4 */ - 55, /* 5 */ - 58, /* 6 */ - 62, /* 7 */ - 65, /* 8 */ - 69, /* 9 */ - 73, /* : */ - 74, /* ; */ - 75, /* < */ - 78, /* = */ - 81, /* > */ - 84, /* ? */ - 88, /* @ */ - 95, /* A */ - 100, /* B */ - 105, /* C */ - 110, /* D */ - 115, /* E */ - 119, /* F */ - 123, /* G */ - 128, /* H */ - 132, /* I */ - 133, /* J */ - 136, /* K */ - 140, /* L */ - 143, /* M */ - 150, /* N */ - 155, /* O */ - 160, /* P */ - 164, /* Q */ - 169, /* R */ - 174, /* S */ - 178, /* T */ - 182, /* U */ - 187, /* V */ - 192, /* W */ - 199, /* X */ - 204, /* Y */ - 209, /* Z */ - 213, /* [ */ - 215, /* \ */ - 217, /* ] */ - 219, /* ^ */ - 222, /* _ */ - 226, /* ` */ - 228, /* a */ - 231, /* b */ - 235, /* c */ - 238, /* d */ - 242, /* e */ - 245, /* f */ - 247, /* g */ - 251, /* h */ - 254, /* i */ - 255, /* j */ - 256, /* k */ - 259, /* l */ - 260, /* m */ - 265, /* n */ - 268, /* o */ - 272, /* p */ - 276, /* q */ - 280, /* r */ - 282, /* s */ - 285, /* t */ - 287, /* u */ - 290, /* v */ - 293, /* w */ - 298, /* x */ - 301, /* y */ - 304, /* z */ - 307, /* { */ - 309, /* | */ - 310, /* } */ - 312, /* ~ */ - 316, /* ß */ - 321, /* ä */ - 324, /* ö */ - 328, /* ü */ - 331 -}; - -unsigned char PROGMEM fontData_small6[] = { - 0x00, /* */ - 0x2f, /* # #### */ - 0x03, /* ## */ - 0x00, /* */ - 0x03, /* ## */ - 0x12, /* # # */ - 0x3f, /* ###### */ - 0x12, /* # # */ - 0x3f, /* ###### */ - 0x12, /* # # */ - 0x26, /* # ## */ - 0x7f, /* ####### */ - 0x32, /* ## # */ - 0x13, /* # ## */ - 0x0b, /* # ## */ - 0x34, /* ## # */ - 0x32, /* ## # */ - 0x1a, /* ## # */ - 0x25, /* # # # */ - 0x1a, /* ## # */ - 0x28, /* # # */ - 0x03, /* ## */ - 0x7e, /* ###### */ - 0x81, /* # # */ - 0x81, /* # # */ - 0x7e, /* ###### */ - 0x03, /* ## */ - 0x03, /* ## */ - 0x08, /* # */ - 0x1c, /* ### */ - 0x08, /* # */ - 0x60, /* ## */ - 0x08, /* # */ - 0x08, /* # */ - 0x20, /* # */ - 0x38, /* ### */ - 0x07, /* ### */ - 0x1e, /* #### */ - 0x21, /* # # */ - 0x21, /* # # */ - 0x1e, /* #### */ - 0x02, /* # */ - 0x3f, /* ###### */ - 0x32, /* ## # */ - 0x29, /* # # # */ - 0x29, /* # # # */ - 0x26, /* # ## */ - 0x12, /* # # */ - 0x21, /* # # */ - 0x25, /* # # # */ - 0x1a, /* ## # */ - 0x18, /* ## */ - 0x16, /* # ## */ - 0x3f, /* ###### */ - 0x10, /* # */ - 0x27, /* # ### */ - 0x25, /* # # # */ - 0x19, /* ## # */ - 0x1e, /* #### */ - 0x25, /* # # # */ - 0x25, /* # # # */ - 0x18, /* ## */ - 0x01, /* # */ - 0x3d, /* #### # */ - 0x03, /* ## */ - 0x1a, /* ## # */ - 0x25, /* # # # */ - 0x25, /* # # # */ - 0x1a, /* ## # */ - 0x12, /* # # */ - 0x25, /* # # # */ - 0x25, /* # # # */ - 0x1e, /* #### */ - 0x24, /* # # */ - 0x64, /* ## # */ - 0x08, /* # */ - 0x14, /* # # */ - 0x22, /* # # */ - 0x14, /* # # */ - 0x14, /* # # */ - 0x14, /* # # */ - 0x22, /* # # */ - 0x14, /* # # */ - 0x08, /* # */ - 0x02, /* # */ - 0x29, /* # # # */ - 0x05, /* # # */ - 0x02, /* # */ - 0x1c, /* ### */ - 0x22, /* # # */ - 0x49, /* # # # */ - 0x55, /* # # # # */ - 0x59, /* # ## # */ - 0x12, /* # # */ - 0x0c, /* ## */ - 0x30, /* ## */ - 0x0c, /* ## */ - 0x0b, /* # ## */ - 0x0c, /* ## */ - 0x30, /* ## */ - 0x3f, /* ###### */ - 0x25, /* # # # */ - 0x25, /* # # # */ - 0x25, /* # # # */ - 0x1a, /* ## # */ - 0x1e, /* #### */ - 0x21, /* # # */ - 0x21, /* # # */ - 0x21, /* # # */ - 0x12, /* # # */ - 0x3f, /* ###### */ - 0x21, /* # # */ - 0x21, /* # # */ - 0x21, /* # # */ - 0x1e, /* #### */ - 0x3f, /* ###### */ - 0x25, /* # # # */ - 0x25, /* # # # */ - 0x21, /* # # */ - 0x3f, /* ###### */ - 0x05, /* # # */ - 0x05, /* # # */ - 0x01, /* # */ - 0x1e, /* #### */ - 0x21, /* # # */ - 0x21, /* # # */ - 0x29, /* # # # */ - 0x3a, /* ### # */ - 0x3f, /* ###### */ - 0x04, /* # */ - 0x04, /* # */ - 0x3f, /* ###### */ - 0x3f, /* ###### */ - 0x30, /* ## */ - 0x20, /* # */ - 0x1f, /* ##### */ - 0x3f, /* ###### */ - 0x0c, /* ## */ - 0x12, /* # # */ - 0x21, /* # # */ - 0x3f, /* ###### */ - 0x20, /* # */ - 0x20, /* # */ - 0x3f, /* ###### */ - 0x03, /* ## */ - 0x0c, /* ## */ - 0x30, /* ## */ - 0x0c, /* ## */ - 0x03, /* ## */ - 0x3f, /* ###### */ - 0x3f, /* ###### */ - 0x03, /* ## */ - 0x0c, /* ## */ - 0x30, /* ## */ - 0x3f, /* ###### */ - 0x1e, /* #### */ - 0x21, /* # # */ - 0x21, /* # # */ - 0x21, /* # # */ - 0x1e, /* #### */ - 0x3f, /* ###### */ - 0x09, /* # # */ - 0x09, /* # # */ - 0x06, /* ## */ - 0x1e, /* #### */ - 0x21, /* # # */ - 0x29, /* # # # */ - 0x11, /* # # */ - 0x2e, /* # ### */ - 0x3f, /* ###### */ - 0x09, /* # # */ - 0x09, /* # # */ - 0x09, /* # # */ - 0x36, /* ## ## */ - 0x12, /* # # */ - 0x25, /* # # # */ - 0x29, /* # # # */ - 0x12, /* # # */ - 0x01, /* # */ - 0x3f, /* ###### */ - 0x01, /* # */ - 0x01, /* # */ - 0x1f, /* ##### */ - 0x20, /* # */ - 0x20, /* # */ - 0x20, /* # */ - 0x1f, /* ##### */ - 0x03, /* ## */ - 0x0c, /* ## */ - 0x30, /* ## */ - 0x0c, /* ## */ - 0x03, /* ## */ - 0x03, /* ## */ - 0x0c, /* ## */ - 0x30, /* ## */ - 0x0c, /* ## */ - 0x30, /* ## */ - 0x0c, /* ## */ - 0x03, /* ## */ - 0x21, /* # # */ - 0x12, /* # # */ - 0x0c, /* ## */ - 0x12, /* # # */ - 0x21, /* # # */ - 0x01, /* # */ - 0x02, /* # */ - 0x3c, /* #### */ - 0x02, /* # */ - 0x01, /* # */ - 0x31, /* ## # */ - 0x29, /* # # # */ - 0x25, /* # # # */ - 0x23, /* # ## */ - 0x7f, /* ####### */ - 0x41, /* # # */ - 0x07, /* ### */ - 0x38, /* ### */ - 0x41, /* # # */ - 0x7f, /* ####### */ - 0x02, /* # */ - 0x01, /* # */ - 0x02, /* # */ - 0x40, /* # */ - 0x40, /* # */ - 0x40, /* # */ - 0x40, /* # */ - 0x00, /* */ - 0x01, /* # */ - 0x14, /* # # */ - 0x24, /* # # */ - 0x38, /* ### */ - 0x3f, /* ###### */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x18, /* ## */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x3f, /* ###### */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x28, /* # # */ - 0x3e, /* ##### */ - 0x05, /* # # */ - 0x18, /* ## */ - 0xa4, /* # # # */ - 0xa4, /* # # # */ - 0x7c, /* ##### */ - 0x3f, /* ###### */ - 0x04, /* # */ - 0x38, /* ### */ - 0x3d, /* #### # */ - 0xfd, /* ###### # */ - 0x3f, /* ###### */ - 0x08, /* # */ - 0x34, /* ## # */ - 0x3f, /* ###### */ - 0x3c, /* #### */ - 0x04, /* # */ - 0x3c, /* #### */ - 0x04, /* # */ - 0x38, /* ### */ - 0x3c, /* #### */ - 0x04, /* # */ - 0x38, /* ### */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x18, /* ## */ - 0xfc, /* ###### */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x18, /* ## */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x24, /* # # */ - 0xfc, /* ###### */ - 0x3c, /* #### */ - 0x04, /* # */ - 0x28, /* # # */ - 0x24, /* # # */ - 0x14, /* # # */ - 0x1e, /* #### */ - 0x24, /* # # */ - 0x1c, /* ### */ - 0x20, /* # */ - 0x3c, /* #### */ - 0x0c, /* ## */ - 0x30, /* ## */ - 0x0c, /* ## */ - 0x0c, /* ## */ - 0x30, /* ## */ - 0x0c, /* ## */ - 0x30, /* ## */ - 0x0c, /* ## */ - 0x24, /* # # */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x9c, /* # ### */ - 0x60, /* ## */ - 0x1c, /* ### */ - 0x34, /* ## # */ - 0x24, /* # # */ - 0x2c, /* # ## */ - 0x08, /* # */ - 0x77, /* ### ### */ - 0x7f, /* ####### */ - 0x77, /* ### ### */ - 0x08, /* # */ - 0x01, /* # */ - 0x02, /* # */ - 0x01, /* # */ - 0x02, /* # */ - 0x3e, /* ##### */ - 0x05, /* # # */ - 0x26, /* # ## */ - 0x18, /* ## */ - 0x19, /* ## # */ - 0x24, /* # # */ - 0x29, /* # # # */ - 0x19, /* ## # */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x19, /* ## # */ - 0x1d, /* ### # */ - 0x20, /* # */ - 0x3d, /* #### # */ -}; - -font font_small6 = {8, fontIndex_small6, fontData_small6, ' ', '~', '.', 1}; +#include "font.h" + +unsigned int PROGMEM fontIndex_small6[] = { + 0, /* */ + 1, /* ! */ + 2, /* " */ + 5, /* # */ + 10, /* $ */ + 13, /* % */ + 17, /* & */ + 21, /* ' */ + 22, /* ( */ + 24, /* ) */ + 26, /* * */ + 28, /* + */ + 31, /* , */ + 32, /* - */ + 34, /* . */ + 35, /* / */ + 37, /* 0 */ + 41, /* 1 */ + 43, /* 2 */ + 47, /* 3 */ + 51, /* 4 */ + 55, /* 5 */ + 58, /* 6 */ + 62, /* 7 */ + 65, /* 8 */ + 69, /* 9 */ + 73, /* : */ + 74, /* ; */ + 75, /* < */ + 78, /* = */ + 81, /* > */ + 84, /* ? */ + 88, /* @ */ + 95, /* A */ + 100, /* B */ + 105, /* C */ + 110, /* D */ + 115, /* E */ + 119, /* F */ + 123, /* G */ + 128, /* H */ + 132, /* I */ + 133, /* J */ + 136, /* K */ + 140, /* L */ + 143, /* M */ + 150, /* N */ + 155, /* O */ + 160, /* P */ + 164, /* Q */ + 169, /* R */ + 174, /* S */ + 178, /* T */ + 182, /* U */ + 187, /* V */ + 192, /* W */ + 199, /* X */ + 204, /* Y */ + 209, /* Z */ + 213, /* [ */ + 215, /* \ */ + 217, /* ] */ + 219, /* ^ */ + 222, /* _ */ + 226, /* ` */ + 228, /* a */ + 231, /* b */ + 235, /* c */ + 238, /* d */ + 242, /* e */ + 245, /* f */ + 247, /* g */ + 251, /* h */ + 254, /* i */ + 255, /* j */ + 256, /* k */ + 259, /* l */ + 260, /* m */ + 265, /* n */ + 268, /* o */ + 272, /* p */ + 276, /* q */ + 280, /* r */ + 282, /* s */ + 285, /* t */ + 287, /* u */ + 290, /* v */ + 293, /* w */ + 298, /* x */ + 301, /* y */ + 304, /* z */ + 307, /* { */ + 309, /* | */ + 310, /* } */ + 312, /* ~ */ + 316, /* ß */ + 321, /* ä */ + 324, /* ö */ + 328, /* ü */ + 331 +}; + +unsigned char PROGMEM fontData_small6[] = { + 0x00, /* */ + 0x2f, /* # #### */ + 0x03, /* ## */ + 0x00, /* */ + 0x03, /* ## */ + 0x12, /* # # */ + 0x3f, /* ###### */ + 0x12, /* # # */ + 0x3f, /* ###### */ + 0x12, /* # # */ + 0x26, /* # ## */ + 0x7f, /* ####### */ + 0x32, /* ## # */ + 0x13, /* # ## */ + 0x0b, /* # ## */ + 0x34, /* ## # */ + 0x32, /* ## # */ + 0x1a, /* ## # */ + 0x25, /* # # # */ + 0x1a, /* ## # */ + 0x28, /* # # */ + 0x03, /* ## */ + 0x7e, /* ###### */ + 0x81, /* # # */ + 0x81, /* # # */ + 0x7e, /* ###### */ + 0x03, /* ## */ + 0x03, /* ## */ + 0x08, /* # */ + 0x1c, /* ### */ + 0x08, /* # */ + 0x60, /* ## */ + 0x08, /* # */ + 0x08, /* # */ + 0x20, /* # */ + 0x38, /* ### */ + 0x07, /* ### */ + 0x1e, /* #### */ + 0x21, /* # # */ + 0x21, /* # # */ + 0x1e, /* #### */ + 0x02, /* # */ + 0x3f, /* ###### */ + 0x32, /* ## # */ + 0x29, /* # # # */ + 0x29, /* # # # */ + 0x26, /* # ## */ + 0x12, /* # # */ + 0x21, /* # # */ + 0x25, /* # # # */ + 0x1a, /* ## # */ + 0x18, /* ## */ + 0x16, /* # ## */ + 0x3f, /* ###### */ + 0x10, /* # */ + 0x27, /* # ### */ + 0x25, /* # # # */ + 0x19, /* ## # */ + 0x1e, /* #### */ + 0x25, /* # # # */ + 0x25, /* # # # */ + 0x18, /* ## */ + 0x01, /* # */ + 0x3d, /* #### # */ + 0x03, /* ## */ + 0x1a, /* ## # */ + 0x25, /* # # # */ + 0x25, /* # # # */ + 0x1a, /* ## # */ + 0x12, /* # # */ + 0x25, /* # # # */ + 0x25, /* # # # */ + 0x1e, /* #### */ + 0x24, /* # # */ + 0x64, /* ## # */ + 0x08, /* # */ + 0x14, /* # # */ + 0x22, /* # # */ + 0x14, /* # # */ + 0x14, /* # # */ + 0x14, /* # # */ + 0x22, /* # # */ + 0x14, /* # # */ + 0x08, /* # */ + 0x02, /* # */ + 0x29, /* # # # */ + 0x05, /* # # */ + 0x02, /* # */ + 0x1c, /* ### */ + 0x22, /* # # */ + 0x49, /* # # # */ + 0x55, /* # # # # */ + 0x59, /* # ## # */ + 0x12, /* # # */ + 0x0c, /* ## */ + 0x30, /* ## */ + 0x0c, /* ## */ + 0x0b, /* # ## */ + 0x0c, /* ## */ + 0x30, /* ## */ + 0x3f, /* ###### */ + 0x25, /* # # # */ + 0x25, /* # # # */ + 0x25, /* # # # */ + 0x1a, /* ## # */ + 0x1e, /* #### */ + 0x21, /* # # */ + 0x21, /* # # */ + 0x21, /* # # */ + 0x12, /* # # */ + 0x3f, /* ###### */ + 0x21, /* # # */ + 0x21, /* # # */ + 0x21, /* # # */ + 0x1e, /* #### */ + 0x3f, /* ###### */ + 0x25, /* # # # */ + 0x25, /* # # # */ + 0x21, /* # # */ + 0x3f, /* ###### */ + 0x05, /* # # */ + 0x05, /* # # */ + 0x01, /* # */ + 0x1e, /* #### */ + 0x21, /* # # */ + 0x21, /* # # */ + 0x29, /* # # # */ + 0x3a, /* ### # */ + 0x3f, /* ###### */ + 0x04, /* # */ + 0x04, /* # */ + 0x3f, /* ###### */ + 0x3f, /* ###### */ + 0x30, /* ## */ + 0x20, /* # */ + 0x1f, /* ##### */ + 0x3f, /* ###### */ + 0x0c, /* ## */ + 0x12, /* # # */ + 0x21, /* # # */ + 0x3f, /* ###### */ + 0x20, /* # */ + 0x20, /* # */ + 0x3f, /* ###### */ + 0x03, /* ## */ + 0x0c, /* ## */ + 0x30, /* ## */ + 0x0c, /* ## */ + 0x03, /* ## */ + 0x3f, /* ###### */ + 0x3f, /* ###### */ + 0x03, /* ## */ + 0x0c, /* ## */ + 0x30, /* ## */ + 0x3f, /* ###### */ + 0x1e, /* #### */ + 0x21, /* # # */ + 0x21, /* # # */ + 0x21, /* # # */ + 0x1e, /* #### */ + 0x3f, /* ###### */ + 0x09, /* # # */ + 0x09, /* # # */ + 0x06, /* ## */ + 0x1e, /* #### */ + 0x21, /* # # */ + 0x29, /* # # # */ + 0x11, /* # # */ + 0x2e, /* # ### */ + 0x3f, /* ###### */ + 0x09, /* # # */ + 0x09, /* # # */ + 0x09, /* # # */ + 0x36, /* ## ## */ + 0x12, /* # # */ + 0x25, /* # # # */ + 0x29, /* # # # */ + 0x12, /* # # */ + 0x01, /* # */ + 0x3f, /* ###### */ + 0x01, /* # */ + 0x01, /* # */ + 0x1f, /* ##### */ + 0x20, /* # */ + 0x20, /* # */ + 0x20, /* # */ + 0x1f, /* ##### */ + 0x03, /* ## */ + 0x0c, /* ## */ + 0x30, /* ## */ + 0x0c, /* ## */ + 0x03, /* ## */ + 0x03, /* ## */ + 0x0c, /* ## */ + 0x30, /* ## */ + 0x0c, /* ## */ + 0x30, /* ## */ + 0x0c, /* ## */ + 0x03, /* ## */ + 0x21, /* # # */ + 0x12, /* # # */ + 0x0c, /* ## */ + 0x12, /* # # */ + 0x21, /* # # */ + 0x01, /* # */ + 0x02, /* # */ + 0x3c, /* #### */ + 0x02, /* # */ + 0x01, /* # */ + 0x31, /* ## # */ + 0x29, /* # # # */ + 0x25, /* # # # */ + 0x23, /* # ## */ + 0x7f, /* ####### */ + 0x41, /* # # */ + 0x07, /* ### */ + 0x38, /* ### */ + 0x41, /* # # */ + 0x7f, /* ####### */ + 0x02, /* # */ + 0x01, /* # */ + 0x02, /* # */ + 0x40, /* # */ + 0x40, /* # */ + 0x40, /* # */ + 0x40, /* # */ + 0x00, /* */ + 0x01, /* # */ + 0x14, /* # # */ + 0x24, /* # # */ + 0x38, /* ### */ + 0x3f, /* ###### */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x18, /* ## */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x3f, /* ###### */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x28, /* # # */ + 0x3e, /* ##### */ + 0x05, /* # # */ + 0x18, /* ## */ + 0xa4, /* # # # */ + 0xa4, /* # # # */ + 0x7c, /* ##### */ + 0x3f, /* ###### */ + 0x04, /* # */ + 0x38, /* ### */ + 0x3d, /* #### # */ + 0xfd, /* ###### # */ + 0x3f, /* ###### */ + 0x08, /* # */ + 0x34, /* ## # */ + 0x3f, /* ###### */ + 0x3c, /* #### */ + 0x04, /* # */ + 0x3c, /* #### */ + 0x04, /* # */ + 0x38, /* ### */ + 0x3c, /* #### */ + 0x04, /* # */ + 0x38, /* ### */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x18, /* ## */ + 0xfc, /* ###### */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x18, /* ## */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x24, /* # # */ + 0xfc, /* ###### */ + 0x3c, /* #### */ + 0x04, /* # */ + 0x28, /* # # */ + 0x24, /* # # */ + 0x14, /* # # */ + 0x1e, /* #### */ + 0x24, /* # # */ + 0x1c, /* ### */ + 0x20, /* # */ + 0x3c, /* #### */ + 0x0c, /* ## */ + 0x30, /* ## */ + 0x0c, /* ## */ + 0x0c, /* ## */ + 0x30, /* ## */ + 0x0c, /* ## */ + 0x30, /* ## */ + 0x0c, /* ## */ + 0x24, /* # # */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x9c, /* # ### */ + 0x60, /* ## */ + 0x1c, /* ### */ + 0x34, /* ## # */ + 0x24, /* # # */ + 0x2c, /* # ## */ + 0x08, /* # */ + 0x77, /* ### ### */ + 0x7f, /* ####### */ + 0x77, /* ### ### */ + 0x08, /* # */ + 0x01, /* # */ + 0x02, /* # */ + 0x01, /* # */ + 0x02, /* # */ + 0x3e, /* ##### */ + 0x05, /* # # */ + 0x26, /* # ## */ + 0x18, /* ## */ + 0x19, /* ## # */ + 0x24, /* # # */ + 0x29, /* # # # */ + 0x19, /* ## # */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x19, /* ## # */ + 0x1d, /* ### # */ + 0x20, /* # */ + 0x3d, /* #### # */ +}; + +font font_small6 = {8, fontIndex_small6, fontData_small6, ' ', '~', '.', 1}; diff --git a/scrolltext/font_small6.h b/src/scrolltext/font_small6.h similarity index 100% rename from scrolltext/font_small6.h rename to src/scrolltext/font_small6.h diff --git a/scrolltext/font_uni53.c b/src/scrolltext/font_uni53.c similarity index 98% rename from scrolltext/font_uni53.c rename to src/scrolltext/font_uni53.c index 5165723..851ebc4 100644 --- a/scrolltext/font_uni53.c +++ b/src/scrolltext/font_uni53.c @@ -1,503 +1,503 @@ -#include "font.h" - -static unsigned int const PROGMEM fontIndex_uni53[] = { 0, /* */ - 1, /* ! */ - 3, /* " */ - 6, /* # */ - 11, /* $ */ - 16, /* % */ - 21, /* & */ - 27, /* ' */ - 28, /* ( */ - 30, /* ) */ - 32, /* * */ - 37, /* + */ - 42, /* , */ - 44, /* - */ - 48, /* . */ - 49, /* / */ - 54, /* 0 */ - 59, /* 1 */ - 61, /* 2 */ - 66, /* 3 */ - 71, /* 4 */ - 76, /* 5 */ - 81, /* 6 */ - 86, /* 7 */ - 90, /* 8 */ - 95, /* 9 */ - 100, /* : */ - 102, /* ; */ - 104, /* < */ - 107, /* = */ - 112, /* > */ - 115, /* ? */ - 119, /* @ */ - 124, /* A */ - 129, /* B */ - 134, /* C */ - 139, /* D */ - 144, /* E */ - 149, /* F */ - 154, /* G */ - 159, /* H */ - 164, /* I */ - 165, /* J */ - 169, /* K */ - 174, /* L */ - 178, /* M */ - 183, /* N */ - 188, /* O */ - 193, /* P */ - 198, /* Q */ - 203, /* R */ - 208, /* S */ - 213, /* T */ - 218, /* U */ - 223, /* V */ - 228, /* W */ - 235, /* X */ - 240, /* Y */ - 245, /* Z */ - 250, /* [ */ - 252, /* \ */ - 257, /* ] */ - 259, /* ^ */ - 262, /* _ */ - 267, /* ` */ - 269, /* a */ - 273, /* b */ - 277, /* c */ - 281, /* d */ - 285, /* e */ - 289, /* f */ - 291, /* g */ - 295, /* h */ - 299, /* i */ - 300, /* j */ - 302, /* k */ - 306, /* l */ - 307, /* m */ - 314, /* n */ - 318, /* o */ - 322, /* p */ - 326, /* q */ - 330, /* r */ - 333, /* s */ - 337, /* t */ - 340, /* u */ - 344, /* v */ - 348, /* w */ - 355, /* x */ - 359, /* y */ - 363, /* z */ - 367, /* { */ - 370, /* | */ - 372, /* } */ - 375, /* ~ */ - 379, /* ß */ - 383, /* ä */ - 387, /* ö */ - 391, /* ü */ - 395 -}; - -static unsigned char const PROGMEM fontData_uni53[] = { - 0x00, /* */ - 0x00, /* */ - 0x2e, /* # ### */ - 0x06, /* ## */ - 0x00, /* */ - 0x06, /* ## */ - 0x14, /* # # */ - 0x3e, /* ##### */ - 0x14, /* # # */ - 0x3e, /* ##### */ - 0x14, /* # # */ - 0x24, /* # # */ - 0x2a, /* # # # */ - 0x6b, /* ## # ## */ - 0x2a, /* # # # */ - 0x12, /* # # */ - 0x22, /* # # */ - 0x10, /* # */ - 0x08, /* # */ - 0x04, /* # */ - 0x22, /* # # */ - 0x14, /* # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x24, /* # # */ - 0x10, /* # */ - 0x06, /* ## */ - 0x3e, /* ##### */ - 0x41, /* # # */ - 0x41, /* # # */ - 0x3e, /* ##### */ - 0x08, /* # */ - 0x2a, /* # # # */ - 0x1c, /* ### */ - 0x2a, /* # # # */ - 0x08, /* # */ - 0x08, /* # */ - 0x08, /* # */ - 0x3e, /* ##### */ - 0x08, /* # */ - 0x08, /* # */ - 0x80, /* # */ - 0x60, /* ## */ - 0x08, /* # */ - 0x08, /* # */ - 0x08, /* # */ - 0x08, /* # */ - 0x20, /* # */ - 0x20, /* # */ - 0x10, /* # */ - 0x08, /* # */ - 0x04, /* # */ - 0x02, /* # */ - 0x1c, /* ### */ - 0x22, /* # # */ - 0x22, /* # # */ - 0x22, /* # # */ - 0x1c, /* ### */ - 0x02, /* # */ - 0x3e, /* ##### */ - 0x32, /* ## # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2c, /* # ## */ - 0x22, /* # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x14, /* # # */ - 0x0e, /* ### */ - 0x08, /* # */ - 0x08, /* # */ - 0x08, /* # */ - 0x3e, /* ##### */ - 0x2e, /* # ### */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x12, /* # # */ - 0x1c, /* ### */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x10, /* # */ - 0x02, /* # */ - 0x02, /* # */ - 0x32, /* ## # */ - 0x0e, /* ### */ - 0x14, /* # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x14, /* # # */ - 0x04, /* # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x1c, /* ### */ - 0x00, /* */ - 0x14, /* # # */ - 0x80, /* # */ - 0x64, /* ## # */ - 0x08, /* # */ - 0x14, /* # # */ - 0x22, /* # # */ - 0x14, /* # # */ - 0x14, /* # # */ - 0x14, /* # # */ - 0x14, /* # # */ - 0x14, /* # # */ - 0x22, /* # # */ - 0x14, /* # # */ - 0x08, /* # */ - 0x02, /* # */ - 0x2a, /* # # # */ - 0x0a, /* # # */ - 0x04, /* # */ - 0x1c, /* ### */ - 0x22, /* # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x0c, /* ## */ - 0x3c, /* #### */ - 0x0a, /* # # */ - 0x0a, /* # # */ - 0x0a, /* # # */ - 0x3c, /* #### */ - 0x3e, /* ##### */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x14, /* # # */ - 0x1c, /* ### */ - 0x22, /* # # */ - 0x22, /* # # */ - 0x22, /* # # */ - 0x14, /* # # */ - 0x3e, /* ##### */ - 0x22, /* # # */ - 0x22, /* # # */ - 0x22, /* # # */ - 0x1c, /* ### */ - 0x3e, /* ##### */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x22, /* # # */ - 0x3e, /* ##### */ - 0x0a, /* # # */ - 0x0a, /* # # */ - 0x0a, /* # # */ - 0x02, /* # */ - 0x1c, /* ### */ - 0x22, /* # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x3a, /* ### # */ - 0x3e, /* ##### */ - 0x08, /* # */ - 0x08, /* # */ - 0x08, /* # */ - 0x3e, /* ##### */ - 0x3e, /* ##### */ - 0x10, /* # */ - 0x20, /* # */ - 0x20, /* # */ - 0x1e, /* #### */ - 0x3e, /* ##### */ - 0x08, /* # */ - 0x08, /* # */ - 0x14, /* # # */ - 0x22, /* # # */ - 0x3e, /* ##### */ - 0x20, /* # */ - 0x20, /* # */ - 0x20, /* # */ - 0x3e, /* ##### */ - 0x04, /* # */ - 0x08, /* # */ - 0x04, /* # */ - 0x3e, /* ##### */ - 0x3e, /* ##### */ - 0x04, /* # */ - 0x08, /* # */ - 0x10, /* # */ - 0x3e, /* ##### */ - 0x1c, /* ### */ - 0x22, /* # # */ - 0x22, /* # # */ - 0x22, /* # # */ - 0x1c, /* ### */ - 0x3e, /* ##### */ - 0x0a, /* # # */ - 0x0a, /* # # */ - 0x0a, /* # # */ - 0x04, /* # */ - 0x1c, /* ### */ - 0x22, /* # # */ - 0x22, /* # # */ - 0x22, /* # # */ - 0x5c, /* # ### */ - 0x3e, /* ##### */ - 0x0a, /* # # */ - 0x0a, /* # # */ - 0x1a, /* ## # */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x2a, /* # # # */ - 0x12, /* # # */ - 0x02, /* # */ - 0x02, /* # */ - 0x3e, /* ##### */ - 0x02, /* # */ - 0x02, /* # */ - 0x1e, /* #### */ - 0x20, /* # */ - 0x20, /* # */ - 0x20, /* # */ - 0x1e, /* #### */ - 0x0e, /* ### */ - 0x10, /* # */ - 0x20, /* # */ - 0x10, /* # */ - 0x0e, /* ### */ - 0x1e, /* #### */ - 0x20, /* # */ - 0x20, /* # */ - 0x1e, /* #### */ - 0x20, /* # */ - 0x20, /* # */ - 0x1e, /* #### */ - 0x22, /* # # */ - 0x14, /* # # */ - 0x08, /* # */ - 0x14, /* # # */ - 0x22, /* # # */ - 0x02, /* # */ - 0x04, /* # */ - 0x38, /* ### */ - 0x04, /* # */ - 0x02, /* # */ - 0x22, /* # # */ - 0x32, /* ## # */ - 0x2a, /* # # # */ - 0x26, /* # ## */ - 0x22, /* # # */ - 0x7f, /* ####### */ - 0x41, /* # # */ - 0x02, /* # */ - 0x04, /* # */ - 0x08, /* # */ - 0x10, /* # */ - 0x20, /* # */ - 0x41, /* # # */ - 0x7f, /* ####### */ - 0x04, /* # */ - 0x02, /* # */ - 0x04, /* # */ - 0x40, /* # */ - 0x40, /* # */ - 0x40, /* # */ - 0x40, /* # */ - 0x40, /* # */ - 0x02, /* # */ - 0x04, /* # */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x38, /* ### */ - 0x3e, /* ##### */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x18, /* ## */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x3e, /* ##### */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x34, /* ## # */ - 0x2c, /* # ## */ - 0x3c, /* #### */ - 0x0a, /* # # */ - 0x18, /* ## */ - 0xa4, /* # # # */ - 0xa4, /* # # # */ - 0x78, /* #### */ - 0x3e, /* ##### */ - 0x04, /* # */ - 0x04, /* # */ - 0x38, /* ### */ - 0x3a, /* ### # */ - 0x80, /* # */ - 0x7a, /* #### # */ - 0x3e, /* ##### */ - 0x10, /* # */ - 0x08, /* # */ - 0x34, /* ## # */ - 0x3e, /* ##### */ - 0x3c, /* #### */ - 0x04, /* # */ - 0x04, /* # */ - 0x38, /* ### */ - 0x04, /* # */ - 0x04, /* # */ - 0x38, /* ### */ - 0x3c, /* #### */ - 0x04, /* # */ - 0x04, /* # */ - 0x38, /* ### */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x18, /* ## */ - 0xfc, /* ###### */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x18, /* ## */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x24, /* # # */ - 0xfc, /* ###### */ - 0x3c, /* #### */ - 0x08, /* # */ - 0x04, /* # */ - 0x28, /* # # */ - 0x2c, /* # ## */ - 0x34, /* ## # */ - 0x14, /* # # */ - 0x04, /* # */ - 0x3e, /* ##### */ - 0x04, /* # */ - 0x1c, /* ### */ - 0x20, /* # */ - 0x20, /* # */ - 0x3c, /* #### */ - 0x1c, /* ### */ - 0x20, /* # */ - 0x20, /* # */ - 0x1c, /* ### */ - 0x1c, /* ### */ - 0x20, /* # */ - 0x20, /* # */ - 0x1c, /* ### */ - 0x20, /* # */ - 0x20, /* # */ - 0x1c, /* ### */ - 0x24, /* # # */ - 0x18, /* ## */ - 0x18, /* ## */ - 0x24, /* # # */ - 0x1c, /* ### */ - 0xa0, /* # # */ - 0xa0, /* # # */ - 0x7c, /* ##### */ - 0x24, /* # # */ - 0x34, /* ## # */ - 0x2c, /* # ## */ - 0x24, /* # # */ - 0x08, /* # */ - 0x36, /* ## ## */ - 0x41, /* # # */ - 0x00, /* */ - 0x7f, /* ####### */ - 0x41, /* # # */ - 0x36, /* ## ## */ - 0x08, /* # */ - 0x08, /* # */ - 0x04, /* # */ - 0x08, /* # */ - 0x04, /* # */ - 0x3c, /* #### */ - 0x02, /* # */ - 0x2a, /* # # # */ - 0x14, /* # # */ - 0x19, /* ## # */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x39, /* ### # */ - 0x19, /* ## # */ - 0x24, /* # # */ - 0x24, /* # # */ - 0x19, /* ## # */ - 0x1d, /* ### # */ - 0x20, /* # */ - 0x20, /* # */ - 0x3d, /* #### # */ -}; - -font font_uni53 = {8, fontIndex_uni53, fontData_uni53, ' ', '~', '.', 1}; +#include "font.h" + +static unsigned int const PROGMEM fontIndex_uni53[] = { 0, /* */ + 1, /* ! */ + 3, /* " */ + 6, /* # */ + 11, /* $ */ + 16, /* % */ + 21, /* & */ + 27, /* ' */ + 28, /* ( */ + 30, /* ) */ + 32, /* * */ + 37, /* + */ + 42, /* , */ + 44, /* - */ + 48, /* . */ + 49, /* / */ + 54, /* 0 */ + 59, /* 1 */ + 61, /* 2 */ + 66, /* 3 */ + 71, /* 4 */ + 76, /* 5 */ + 81, /* 6 */ + 86, /* 7 */ + 90, /* 8 */ + 95, /* 9 */ + 100, /* : */ + 102, /* ; */ + 104, /* < */ + 107, /* = */ + 112, /* > */ + 115, /* ? */ + 119, /* @ */ + 124, /* A */ + 129, /* B */ + 134, /* C */ + 139, /* D */ + 144, /* E */ + 149, /* F */ + 154, /* G */ + 159, /* H */ + 164, /* I */ + 165, /* J */ + 169, /* K */ + 174, /* L */ + 178, /* M */ + 183, /* N */ + 188, /* O */ + 193, /* P */ + 198, /* Q */ + 203, /* R */ + 208, /* S */ + 213, /* T */ + 218, /* U */ + 223, /* V */ + 228, /* W */ + 235, /* X */ + 240, /* Y */ + 245, /* Z */ + 250, /* [ */ + 252, /* \ */ + 257, /* ] */ + 259, /* ^ */ + 262, /* _ */ + 267, /* ` */ + 269, /* a */ + 273, /* b */ + 277, /* c */ + 281, /* d */ + 285, /* e */ + 289, /* f */ + 291, /* g */ + 295, /* h */ + 299, /* i */ + 300, /* j */ + 302, /* k */ + 306, /* l */ + 307, /* m */ + 314, /* n */ + 318, /* o */ + 322, /* p */ + 326, /* q */ + 330, /* r */ + 333, /* s */ + 337, /* t */ + 340, /* u */ + 344, /* v */ + 348, /* w */ + 355, /* x */ + 359, /* y */ + 363, /* z */ + 367, /* { */ + 370, /* | */ + 372, /* } */ + 375, /* ~ */ + 379, /* ß */ + 383, /* ä */ + 387, /* ö */ + 391, /* ü */ + 395 +}; + +static unsigned char const PROGMEM fontData_uni53[] = { + 0x00, /* */ + 0x00, /* */ + 0x2e, /* # ### */ + 0x06, /* ## */ + 0x00, /* */ + 0x06, /* ## */ + 0x14, /* # # */ + 0x3e, /* ##### */ + 0x14, /* # # */ + 0x3e, /* ##### */ + 0x14, /* # # */ + 0x24, /* # # */ + 0x2a, /* # # # */ + 0x6b, /* ## # ## */ + 0x2a, /* # # # */ + 0x12, /* # # */ + 0x22, /* # # */ + 0x10, /* # */ + 0x08, /* # */ + 0x04, /* # */ + 0x22, /* # # */ + 0x14, /* # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x24, /* # # */ + 0x10, /* # */ + 0x06, /* ## */ + 0x3e, /* ##### */ + 0x41, /* # # */ + 0x41, /* # # */ + 0x3e, /* ##### */ + 0x08, /* # */ + 0x2a, /* # # # */ + 0x1c, /* ### */ + 0x2a, /* # # # */ + 0x08, /* # */ + 0x08, /* # */ + 0x08, /* # */ + 0x3e, /* ##### */ + 0x08, /* # */ + 0x08, /* # */ + 0x80, /* # */ + 0x60, /* ## */ + 0x08, /* # */ + 0x08, /* # */ + 0x08, /* # */ + 0x08, /* # */ + 0x20, /* # */ + 0x20, /* # */ + 0x10, /* # */ + 0x08, /* # */ + 0x04, /* # */ + 0x02, /* # */ + 0x1c, /* ### */ + 0x22, /* # # */ + 0x22, /* # # */ + 0x22, /* # # */ + 0x1c, /* ### */ + 0x02, /* # */ + 0x3e, /* ##### */ + 0x32, /* ## # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2c, /* # ## */ + 0x22, /* # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x14, /* # # */ + 0x0e, /* ### */ + 0x08, /* # */ + 0x08, /* # */ + 0x08, /* # */ + 0x3e, /* ##### */ + 0x2e, /* # ### */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x12, /* # # */ + 0x1c, /* ### */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x10, /* # */ + 0x02, /* # */ + 0x02, /* # */ + 0x32, /* ## # */ + 0x0e, /* ### */ + 0x14, /* # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x14, /* # # */ + 0x04, /* # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x1c, /* ### */ + 0x00, /* */ + 0x14, /* # # */ + 0x80, /* # */ + 0x64, /* ## # */ + 0x08, /* # */ + 0x14, /* # # */ + 0x22, /* # # */ + 0x14, /* # # */ + 0x14, /* # # */ + 0x14, /* # # */ + 0x14, /* # # */ + 0x14, /* # # */ + 0x22, /* # # */ + 0x14, /* # # */ + 0x08, /* # */ + 0x02, /* # */ + 0x2a, /* # # # */ + 0x0a, /* # # */ + 0x04, /* # */ + 0x1c, /* ### */ + 0x22, /* # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x0c, /* ## */ + 0x3c, /* #### */ + 0x0a, /* # # */ + 0x0a, /* # # */ + 0x0a, /* # # */ + 0x3c, /* #### */ + 0x3e, /* ##### */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x14, /* # # */ + 0x1c, /* ### */ + 0x22, /* # # */ + 0x22, /* # # */ + 0x22, /* # # */ + 0x14, /* # # */ + 0x3e, /* ##### */ + 0x22, /* # # */ + 0x22, /* # # */ + 0x22, /* # # */ + 0x1c, /* ### */ + 0x3e, /* ##### */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x22, /* # # */ + 0x3e, /* ##### */ + 0x0a, /* # # */ + 0x0a, /* # # */ + 0x0a, /* # # */ + 0x02, /* # */ + 0x1c, /* ### */ + 0x22, /* # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x3a, /* ### # */ + 0x3e, /* ##### */ + 0x08, /* # */ + 0x08, /* # */ + 0x08, /* # */ + 0x3e, /* ##### */ + 0x3e, /* ##### */ + 0x10, /* # */ + 0x20, /* # */ + 0x20, /* # */ + 0x1e, /* #### */ + 0x3e, /* ##### */ + 0x08, /* # */ + 0x08, /* # */ + 0x14, /* # # */ + 0x22, /* # # */ + 0x3e, /* ##### */ + 0x20, /* # */ + 0x20, /* # */ + 0x20, /* # */ + 0x3e, /* ##### */ + 0x04, /* # */ + 0x08, /* # */ + 0x04, /* # */ + 0x3e, /* ##### */ + 0x3e, /* ##### */ + 0x04, /* # */ + 0x08, /* # */ + 0x10, /* # */ + 0x3e, /* ##### */ + 0x1c, /* ### */ + 0x22, /* # # */ + 0x22, /* # # */ + 0x22, /* # # */ + 0x1c, /* ### */ + 0x3e, /* ##### */ + 0x0a, /* # # */ + 0x0a, /* # # */ + 0x0a, /* # # */ + 0x04, /* # */ + 0x1c, /* ### */ + 0x22, /* # # */ + 0x22, /* # # */ + 0x22, /* # # */ + 0x5c, /* # ### */ + 0x3e, /* ##### */ + 0x0a, /* # # */ + 0x0a, /* # # */ + 0x1a, /* ## # */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x2a, /* # # # */ + 0x12, /* # # */ + 0x02, /* # */ + 0x02, /* # */ + 0x3e, /* ##### */ + 0x02, /* # */ + 0x02, /* # */ + 0x1e, /* #### */ + 0x20, /* # */ + 0x20, /* # */ + 0x20, /* # */ + 0x1e, /* #### */ + 0x0e, /* ### */ + 0x10, /* # */ + 0x20, /* # */ + 0x10, /* # */ + 0x0e, /* ### */ + 0x1e, /* #### */ + 0x20, /* # */ + 0x20, /* # */ + 0x1e, /* #### */ + 0x20, /* # */ + 0x20, /* # */ + 0x1e, /* #### */ + 0x22, /* # # */ + 0x14, /* # # */ + 0x08, /* # */ + 0x14, /* # # */ + 0x22, /* # # */ + 0x02, /* # */ + 0x04, /* # */ + 0x38, /* ### */ + 0x04, /* # */ + 0x02, /* # */ + 0x22, /* # # */ + 0x32, /* ## # */ + 0x2a, /* # # # */ + 0x26, /* # ## */ + 0x22, /* # # */ + 0x7f, /* ####### */ + 0x41, /* # # */ + 0x02, /* # */ + 0x04, /* # */ + 0x08, /* # */ + 0x10, /* # */ + 0x20, /* # */ + 0x41, /* # # */ + 0x7f, /* ####### */ + 0x04, /* # */ + 0x02, /* # */ + 0x04, /* # */ + 0x40, /* # */ + 0x40, /* # */ + 0x40, /* # */ + 0x40, /* # */ + 0x40, /* # */ + 0x02, /* # */ + 0x04, /* # */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x38, /* ### */ + 0x3e, /* ##### */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x18, /* ## */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x3e, /* ##### */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x34, /* ## # */ + 0x2c, /* # ## */ + 0x3c, /* #### */ + 0x0a, /* # # */ + 0x18, /* ## */ + 0xa4, /* # # # */ + 0xa4, /* # # # */ + 0x78, /* #### */ + 0x3e, /* ##### */ + 0x04, /* # */ + 0x04, /* # */ + 0x38, /* ### */ + 0x3a, /* ### # */ + 0x80, /* # */ + 0x7a, /* #### # */ + 0x3e, /* ##### */ + 0x10, /* # */ + 0x08, /* # */ + 0x34, /* ## # */ + 0x3e, /* ##### */ + 0x3c, /* #### */ + 0x04, /* # */ + 0x04, /* # */ + 0x38, /* ### */ + 0x04, /* # */ + 0x04, /* # */ + 0x38, /* ### */ + 0x3c, /* #### */ + 0x04, /* # */ + 0x04, /* # */ + 0x38, /* ### */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x18, /* ## */ + 0xfc, /* ###### */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x18, /* ## */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x24, /* # # */ + 0xfc, /* ###### */ + 0x3c, /* #### */ + 0x08, /* # */ + 0x04, /* # */ + 0x28, /* # # */ + 0x2c, /* # ## */ + 0x34, /* ## # */ + 0x14, /* # # */ + 0x04, /* # */ + 0x3e, /* ##### */ + 0x04, /* # */ + 0x1c, /* ### */ + 0x20, /* # */ + 0x20, /* # */ + 0x3c, /* #### */ + 0x1c, /* ### */ + 0x20, /* # */ + 0x20, /* # */ + 0x1c, /* ### */ + 0x1c, /* ### */ + 0x20, /* # */ + 0x20, /* # */ + 0x1c, /* ### */ + 0x20, /* # */ + 0x20, /* # */ + 0x1c, /* ### */ + 0x24, /* # # */ + 0x18, /* ## */ + 0x18, /* ## */ + 0x24, /* # # */ + 0x1c, /* ### */ + 0xa0, /* # # */ + 0xa0, /* # # */ + 0x7c, /* ##### */ + 0x24, /* # # */ + 0x34, /* ## # */ + 0x2c, /* # ## */ + 0x24, /* # # */ + 0x08, /* # */ + 0x36, /* ## ## */ + 0x41, /* # # */ + 0x00, /* */ + 0x7f, /* ####### */ + 0x41, /* # # */ + 0x36, /* ## ## */ + 0x08, /* # */ + 0x08, /* # */ + 0x04, /* # */ + 0x08, /* # */ + 0x04, /* # */ + 0x3c, /* #### */ + 0x02, /* # */ + 0x2a, /* # # # */ + 0x14, /* # # */ + 0x19, /* ## # */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x39, /* ### # */ + 0x19, /* ## # */ + 0x24, /* # # */ + 0x24, /* # # */ + 0x19, /* ## # */ + 0x1d, /* ### # */ + 0x20, /* # */ + 0x20, /* # */ + 0x3d, /* #### # */ +}; + +font font_uni53 = {8, fontIndex_uni53, fontData_uni53, ' ', '~', '.', 1}; diff --git a/scrolltext/font_uni53.h b/src/scrolltext/font_uni53.h similarity index 100% rename from scrolltext/font_uni53.h rename to src/scrolltext/font_uni53.h diff --git a/scrolltext/scrolltext.h b/src/scrolltext/scrolltext.h similarity index 100% rename from scrolltext/scrolltext.h rename to src/scrolltext/scrolltext.h diff --git a/scrolltext/scrolltext3.c b/src/scrolltext/scrolltext3.c similarity index 100% rename from scrolltext/scrolltext3.c rename to src/scrolltext/scrolltext3.c diff --git a/simulator/Makefile b/src/simulator/Makefile similarity index 56% rename from simulator/Makefile rename to src/simulator/Makefile index e6c98c5..683e1fa 100644 --- a/simulator/Makefile +++ b/src/simulator/Makefile @@ -1,7 +1,8 @@ -TARGET = libanimations.a -TOPDIR = .. +MAKETOPDIR = ../.. -include $(TOPDIR)/defaults.mk +TARGET = libanimations.a + +include $(MAKETOPDIR)/defaults.mk ifeq ($(findstring CYGWIN,$(OSTYPE)),CYGWIN) SRC_SIM = winmain.c eeprom.c @@ -9,4 +10,6 @@ else SRC_SIM = main.c trackball.c eeprom.c endif -include $(TOPDIR)/rules.mk +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/simulator/eeprom.c b/src/simulator/eeprom.c similarity index 100% rename from simulator/eeprom.c rename to src/simulator/eeprom.c diff --git a/simulator/main.c b/src/simulator/main.c similarity index 95% rename from simulator/main.c rename to src/simulator/main.c index db499f7..202feb2 100644 --- a/simulator/main.c +++ b/src/simulator/main.c @@ -1,324 +1,324 @@ -/** - * \defgroup unixsimulator Simulation of the Borg API for UNIX like platforms. - */ -/*@{*/ - -/** - * @file main.c - * @brief Simulator for Unix like platforms. - * @author Martin Ongsiek, Peter Fuhrmann, Christian Kroll - */ - -#ifdef OSX_ - #include -#else - #include -#endif -#include -#include -#include -#include -#include - -#include -#include - -#include "../config.h" -#include "../display_loop.h" -#include "trackball.h" - -/** Number of bytes per row. */ -#define LINEBYTES (((NUM_COLS - 1) / 8) + 1) - -/** Fake port for simulating joystick input. */ -volatile unsigned char fakeport; -/** Flag which indicates if wait should jump to the menu if fire is pressed. */ -volatile unsigned char waitForFire; -/** The simulated frame buffer of the borg. */ -volatile unsigned char pixmap[NUMPLANE][NUM_ROWS][LINEBYTES]; -/** Jump buffer which leads directly the menu. */ -extern jmp_buf newmode_jmpbuf; - -/** Width of the window. */ -int WindWidth; -/** Height of the window. */ -int WindHeight; - -/** Rotation of the x-axis of the scene. */ -float view_rotx = 0; -/** Rotation of the y-axis of the scene. */ -float view_roty = 0; -/** Rotation of the z-axis of the scene. */ -float view_rotz = 0; - -/** GLUT window handle. */ -int win; - - -/** - * Simple wait function. - * @param ms The requested delay in milliseconds. - */ -void wait(unsigned int ms) { - if (waitForFire) { - if (fakeport & 0x01) { - longjmp(newmode_jmpbuf, 43); - } - } - - usleep(ms * 1000); -} - - -/** - * Draw a LED in the given color (which is a list). - * @param color List which contains a sphere. - * @param pos_x x-coordinate - * @param pos_y y-coordinate - * @param pos_z z-coordinate - */ -void drawLED(int color, float pos_x, float pos_y, float pos_z) { - glPushMatrix(); - glTranslatef(pos_x, pos_y, pos_z); - glCallList(color); - glPopMatrix(); -} - - -/** - * Draws the LED matrix. - */ -void display(void) { - int x, y, z, level, color; - tbReshape(WindWidth, WindHeight); - glClear(GL_COLOR_BUFFER_BIT); - glPushMatrix(); - glTranslatef(NUM_COLS * 2., 0., NUM_ROWS * 2.); - tbMatrix(); - glRotatef(view_rotx, 1.0, 0.0, 0.0); - glRotatef(view_roty, 0.0, 1.0, 0.0); - glRotatef(view_rotz, 0.0, 0.0, 1.0); - glTranslatef(-NUM_COLS * 2, 0., -NUM_ROWS * 2.); - for (x = 0; x < 1; x++) { - for (y = 0; y < NUM_COLS; y++) { - for (z = 0; z < NUM_ROWS; z++) { - color = 0; - for (level = 0; level < NUMPLANE; level++) { - if (pixmap[level][z % NUM_ROWS][y / 8] & (1 << y % 8)) { - color = level + 1; - } - } - drawLED(color, (float) y * 4.0, (float) x * 4.0, - (float) (NUM_ROWS - 1 - z) * 4.0); - } - } - } - glPopMatrix(); - glutSwapBuffers(); - - usleep(20000); -} - - -/** - * Handler for processing key presses. - * @param key The pressed key encoded in ASCII. - * @param x X-position of the mouse pointer. - * @param y Y-position of the mouse pointer. - */ -void keyboard(unsigned char key, int x, int y) { - switch (key) { - case 'q': - printf("Quit\n"); - glutDestroyWindow(win); - exit(0); - break; - case ' ': - fakeport |= 0x01; - break; - case 'a': - fakeport |= 0x02; - break; - case 'd': - fakeport |= 0x04; - break; - case 's': - fakeport |= 0x08; - break; - case 'w': - fakeport |= 0x10; - break; - } -} - - -/** - * Handler for processing key releases. - * @param key The released key encoded in ASCII. - * @param x X-position of the mouse pointer. - * @param y Y-position of the mouse pointer. - */ -void keyboardup(unsigned char key, int x, int y) { - switch (key) { - case ' ': - fakeport &= ~0x01; - break; - case 'a': - fakeport &= ~0x02; - break; - case 'd': - fakeport &= ~0x04; - break; - case 's': - fakeport &= ~0x08; - break; - case 'w': - fakeport &= ~0x10; - break; - } -} - - -/** - * Relays mouse position and button state to the trackball implementation. - * @param button Currently monitored button. - * @param state State of that button. - * @param x X-position of the mouse pointer. - * @param y Y-position of the mouse pointer. - */ -void mouse(int button, int state, int x, int y) { - tbMouse(button, state, x, y); -} - - -/** - * Relays motion request to the trackball implementation. - * @param x X-position for the motion direction. - * @param y Y-position for the motion direction. - */ -void motion(int x, int y) { - tbMotion(x, y); -} - -/** - * Updating the window size. - * @param width Width of the window. - * @param height Height of the window. - */ -void reshape(int width, int height) { - - tbReshape(width, height); - - glViewport(0, 0, width, height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, (float) WindWidth / (float) WindWidth, 5., 1000.); - gluLookAt(NUM_ROWS * 2., NUM_ROWS * 2. + 50., NUM_COLS * 2., NUM_ROWS * 2., - NUM_ROWS * 2., NUM_COLS * 2., 0.0, 0.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - WindWidth = width; - WindHeight = height; -} - - -/** - * Handler for special keys (the arrow keys in particular) for adjusting the - * view angle of the scene. - * @param k The pressed special key using GLUT's nomenclature. - * @param x X-position of the mouse pointer. - * @param y Y-position of the mouse pointer. - */ -static void special(int k, int x, int y) { - switch (k) { - case GLUT_KEY_UP: - view_rotx += 5.0; - break; - case GLUT_KEY_DOWN: - view_rotx -= 5.0; - break; - case GLUT_KEY_LEFT: - view_rotz += 5.0; - break; - case GLUT_KEY_RIGHT: - view_rotz -= 5.0; - break; - default: - return; - } - glutPostRedisplay(); -} - - -/** - * Entry point for starting the display loop thread. - * @param unused Not used. Only here to satisfy signature constraints. - */ -void *display_loop_run(void * unused) { - display_loop(); - return 0; -} - - -/** - * Main function for the simulator. - * @param argc The argument count. - * @param argv Command line arguments. - * @return Exit codem, always zero. - */ -int main(int argc, char **argv) { - WindHeight = 700; - WindWidth = 700; - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); - glutInitWindowSize(WindHeight, WindWidth); - win = glutCreateWindow("16x16 Borg Simulator"); - - // callback - glutDisplayFunc(display); - glutIdleFunc(display); - glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); - glutKeyboardFunc(keyboard); - glutKeyboardUpFunc(keyboardup); - glutSpecialFunc(special); - glutMouseFunc(mouse); - glutMotionFunc(motion); - - // clearcolor & main loop - glClearColor(0, 0, 0, 1.0); - gluPerspective(60.0, (float) WindWidth / (float) WindWidth, 5., 1000.); - gluLookAt(NUM_COLS * 2., NUM_COLS * 2. + 50., NUM_ROWS * 2., NUM_COLS * 2., - NUM_COLS * 2., NUM_ROWS * 2., 0.0, 0.0, 1.0); - - // init Call List for LED - GLUquadric* quad = gluNewQuadric(); - glNewList(0, GL_COMPILE); - glColor4f(0.8, 0.0, 0.0, 1.); - gluSphere(quad, 1.0, 12, 12); - glEndList(); - glNewList(1, GL_COMPILE); - glColor4f(0.5, 0.0, 0.0, 1.); - gluSphere(quad, 1.4, 12, 12); - glEndList(); - glNewList(2, GL_COMPILE); - glColor4f(0.7, 0.0, 0.0, 1.); - gluSphere(quad, 1.55, 12, 12); - glEndList(); - glNewList(3, GL_COMPILE); - glColor4f(1.00, 0.0, 0.0, 1.); - gluSphere(quad, 1.7, 12, 12); - glEndList(); - - tbInit(GLUT_LEFT_BUTTON); - tbAnimate(GL_FALSE); - - pthread_t simthread; - pthread_create(&simthread, NULL, display_loop_run, NULL); - - glutMainLoop(); - return 0; -} - -/*@}*/ +/** + * \defgroup unixsimulator Simulation of the Borg API for UNIX like platforms. + */ +/*@{*/ + +/** + * @file main.c + * @brief Simulator for Unix like platforms. + * @author Martin Ongsiek, Peter Fuhrmann, Christian Kroll + */ + +#ifdef OSX_ + #include +#else + #include +#endif +#include +#include +#include +#include +#include + +#include +#include + +#include "../config.h" +#include "../display_loop.h" +#include "trackball.h" + +/** Number of bytes per row. */ +#define LINEBYTES (((NUM_COLS - 1) / 8) + 1) + +/** Fake port for simulating joystick input. */ +volatile unsigned char fakeport; +/** Flag which indicates if wait should jump to the menu if fire is pressed. */ +volatile unsigned char waitForFire; +/** The simulated frame buffer of the borg. */ +volatile unsigned char pixmap[NUMPLANE][NUM_ROWS][LINEBYTES]; +/** Jump buffer which leads directly the menu. */ +extern jmp_buf newmode_jmpbuf; + +/** Width of the window. */ +int WindWidth; +/** Height of the window. */ +int WindHeight; + +/** Rotation of the x-axis of the scene. */ +float view_rotx = 0; +/** Rotation of the y-axis of the scene. */ +float view_roty = 0; +/** Rotation of the z-axis of the scene. */ +float view_rotz = 0; + +/** GLUT window handle. */ +int win; + + +/** + * Simple wait function. + * @param ms The requested delay in milliseconds. + */ +void wait(unsigned int ms) { + if (waitForFire) { + if (fakeport & 0x01) { + longjmp(newmode_jmpbuf, 43); + } + } + + usleep(ms * 1000); +} + + +/** + * Draw a LED in the given color (which is a list). + * @param color List which contains a sphere. + * @param pos_x x-coordinate + * @param pos_y y-coordinate + * @param pos_z z-coordinate + */ +void drawLED(int color, float pos_x, float pos_y, float pos_z) { + glPushMatrix(); + glTranslatef(pos_x, pos_y, pos_z); + glCallList(color); + glPopMatrix(); +} + + +/** + * Draws the LED matrix. + */ +void display(void) { + int x, y, z, level, color; + tbReshape(WindWidth, WindHeight); + glClear(GL_COLOR_BUFFER_BIT); + glPushMatrix(); + glTranslatef(NUM_COLS * 2., 0., NUM_ROWS * 2.); + tbMatrix(); + glRotatef(view_rotx, 1.0, 0.0, 0.0); + glRotatef(view_roty, 0.0, 1.0, 0.0); + glRotatef(view_rotz, 0.0, 0.0, 1.0); + glTranslatef(-NUM_COLS * 2, 0., -NUM_ROWS * 2.); + for (x = 0; x < 1; x++) { + for (y = 0; y < NUM_COLS; y++) { + for (z = 0; z < NUM_ROWS; z++) { + color = 0; + for (level = 0; level < NUMPLANE; level++) { + if (pixmap[level][z % NUM_ROWS][y / 8] & (1 << y % 8)) { + color = level + 1; + } + } + drawLED(color, (float) y * 4.0, (float) x * 4.0, + (float) (NUM_ROWS - 1 - z) * 4.0); + } + } + } + glPopMatrix(); + glutSwapBuffers(); + + usleep(20000); +} + + +/** + * Handler for processing key presses. + * @param key The pressed key encoded in ASCII. + * @param x X-position of the mouse pointer. + * @param y Y-position of the mouse pointer. + */ +void keyboard(unsigned char key, int x, int y) { + switch (key) { + case 'q': + printf("Quit\n"); + glutDestroyWindow(win); + exit(0); + break; + case ' ': + fakeport |= 0x01; + break; + case 'a': + fakeport |= 0x02; + break; + case 'd': + fakeport |= 0x04; + break; + case 's': + fakeport |= 0x08; + break; + case 'w': + fakeport |= 0x10; + break; + } +} + + +/** + * Handler for processing key releases. + * @param key The released key encoded in ASCII. + * @param x X-position of the mouse pointer. + * @param y Y-position of the mouse pointer. + */ +void keyboardup(unsigned char key, int x, int y) { + switch (key) { + case ' ': + fakeport &= ~0x01; + break; + case 'a': + fakeport &= ~0x02; + break; + case 'd': + fakeport &= ~0x04; + break; + case 's': + fakeport &= ~0x08; + break; + case 'w': + fakeport &= ~0x10; + break; + } +} + + +/** + * Relays mouse position and button state to the trackball implementation. + * @param button Currently monitored button. + * @param state State of that button. + * @param x X-position of the mouse pointer. + * @param y Y-position of the mouse pointer. + */ +void mouse(int button, int state, int x, int y) { + tbMouse(button, state, x, y); +} + + +/** + * Relays motion request to the trackball implementation. + * @param x X-position for the motion direction. + * @param y Y-position for the motion direction. + */ +void motion(int x, int y) { + tbMotion(x, y); +} + +/** + * Updating the window size. + * @param width Width of the window. + * @param height Height of the window. + */ +void reshape(int width, int height) { + + tbReshape(width, height); + + glViewport(0, 0, width, height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, (float) WindWidth / (float) WindWidth, 5., 1000.); + gluLookAt(NUM_ROWS * 2., NUM_ROWS * 2. + 50., NUM_COLS * 2., NUM_ROWS * 2., + NUM_ROWS * 2., NUM_COLS * 2., 0.0, 0.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + WindWidth = width; + WindHeight = height; +} + + +/** + * Handler for special keys (the arrow keys in particular) for adjusting the + * view angle of the scene. + * @param k The pressed special key using GLUT's nomenclature. + * @param x X-position of the mouse pointer. + * @param y Y-position of the mouse pointer. + */ +static void special(int k, int x, int y) { + switch (k) { + case GLUT_KEY_UP: + view_rotx += 5.0; + break; + case GLUT_KEY_DOWN: + view_rotx -= 5.0; + break; + case GLUT_KEY_LEFT: + view_rotz += 5.0; + break; + case GLUT_KEY_RIGHT: + view_rotz -= 5.0; + break; + default: + return; + } + glutPostRedisplay(); +} + + +/** + * Entry point for starting the display loop thread. + * @param unused Not used. Only here to satisfy signature constraints. + */ +void *display_loop_run(void * unused) { + display_loop(); + return 0; +} + + +/** + * Main function for the simulator. + * @param argc The argument count. + * @param argv Command line arguments. + * @return Exit codem, always zero. + */ +int main(int argc, char **argv) { + WindHeight = 700; + WindWidth = 700; + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); + glutInitWindowSize(WindHeight, WindWidth); + win = glutCreateWindow("16x16 Borg Simulator"); + + // callback + glutDisplayFunc(display); + glutIdleFunc(display); + glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); + glutKeyboardFunc(keyboard); + glutKeyboardUpFunc(keyboardup); + glutSpecialFunc(special); + glutMouseFunc(mouse); + glutMotionFunc(motion); + + // clearcolor & main loop + glClearColor(0, 0, 0, 1.0); + gluPerspective(60.0, (float) WindWidth / (float) WindWidth, 5., 1000.); + gluLookAt(NUM_COLS * 2., NUM_COLS * 2. + 50., NUM_ROWS * 2., NUM_COLS * 2., + NUM_COLS * 2., NUM_ROWS * 2., 0.0, 0.0, 1.0); + + // init Call List for LED + GLUquadric* quad = gluNewQuadric(); + glNewList(0, GL_COMPILE); + glColor4f(0.8, 0.0, 0.0, 1.); + gluSphere(quad, 1.0, 12, 12); + glEndList(); + glNewList(1, GL_COMPILE); + glColor4f(0.5, 0.0, 0.0, 1.); + gluSphere(quad, 1.4, 12, 12); + glEndList(); + glNewList(2, GL_COMPILE); + glColor4f(0.7, 0.0, 0.0, 1.); + gluSphere(quad, 1.55, 12, 12); + glEndList(); + glNewList(3, GL_COMPILE); + glColor4f(1.00, 0.0, 0.0, 1.); + gluSphere(quad, 1.7, 12, 12); + glEndList(); + + tbInit(GLUT_LEFT_BUTTON); + tbAnimate(GL_FALSE); + + pthread_t simthread; + pthread_create(&simthread, NULL, display_loop_run, NULL); + + glutMainLoop(); + return 0; +} + +/*@}*/ diff --git a/simulator/trackball.c b/src/simulator/trackball.c similarity index 95% rename from simulator/trackball.c rename to src/simulator/trackball.c index edbad02..8bbc5e7 100644 --- a/simulator/trackball.c +++ b/src/simulator/trackball.c @@ -1,295 +1,295 @@ -/** - * \addtogroup unixsimulator - */ -/*@{*/ - -/** - * Simple trackball-like motion adapted (ripped off) from projtex.c - * (written by David Yu and David Blythe). See the SIGGRAPH '96 - * Advanced OpenGL course notes. - * - * - * Usage: - * - * o call tbInit() in before any other tb call - * o call tbReshape() from the reshape callback - * o call tbMatrix() to get the trackball matrix rotation - * o call tbStartMotion() to begin trackball movememt - * o call tbStopMotion() to stop trackball movememt - * o call tbMotion() from the motion callback - * o call tbAnimate(GL_TRUE) if you want the trackball to continue - * spinning after the mouse button has been released - * o call tbAnimate(GL_FALSE) if you want the trackball to stop - * spinning after the mouse button has been released - * - * Typical setup: - * - * - * void - * init(void) - * { - * tbInit(GLUT_MIDDLE_BUTTON); - * tbAnimate(GL_TRUE); - * . . . - * } - * - * void - * reshape(int width, int height) - * { - * tbReshape(width, height); - * . . . - * } - * - * void - * display(void) - * { - * glPushMatrix(); - * - * tbMatrix(); - * . . . draw the scene . . . - * - * glPopMatrix(); - * } - * - * void - * mouse(int button, int state, int x, int y) - * { - * tbMouse(button, state, x, y); - * . . . - * } - * - * void - * motion(int x, int y) - * { - * tbMotion(x, y); - * . . . - * } - * - * int - * main(int argc, char** argv) - * { - * . . . - * init(); - * glutReshapeFunc(reshape); - * glutDisplayFunc(display); - * glutMouseFunc(mouse); - * glutMotionFunc(motion); - * . . . - * } - * - * @file trackball.c - * @brief Helper functions for the UNIX platform Borg simulator. - * @author Martin Ongsiek, David Yu, David Blythe - */ - -/* includes */ -#include -#include -#ifdef OSX_ -# include -#else -# include -#endif -#include "trackball.h" - - -/* globals */ -static GLuint tb_lasttime; -static GLfloat tb_lastposition[3]; - -static GLfloat tb_angle = 0.0; -static GLfloat tb_axis[3]; -static GLfloat tb_transform[4][4]; - -static GLuint tb_width; -static GLuint tb_height; - -static GLint tb_button = -1; -static GLboolean tb_tracking = GL_FALSE; -static GLboolean tb_animate = GL_TRUE; - - -/* functions */ - -/** - * Project x and y onto a hemisphere centered within given width and height. - * @param x X-coordinate - * @param y Y-coordinate - * @param width Width of the hemisphere. - * @param height Width of the hemisphere. - * @param v Vector where the projection is performed on. - */ -static void _tbPointToVector(int x, int y, int width, int height, float v[3]) { - float d, a; - - /* project x, y onto a hemisphere centered within width, height. */ - v[0] = (2.0 * x - width) / width; - v[1] = (height - 2.0 * y) / height; - d = sqrt(v[0] * v[0] + v[1] * v[1]); - v[2] = cos((3.14159265 / 2.0) * ((d < 1.0) ? d : 1.0)); - a = 1.0 / sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); - v[0] *= a; - v[1] *= a; - v[2] *= a; -} - - -/** - * Redisplay current window contents. - */ -static void _tbAnimate(void) { - glutPostRedisplay(); -} - - -/** - * Starts trackball movement depending on the mouse position. - * @param x X-position of the mouse pointer. - * @param y Y-position of the mouse pointer. - * @param button Not used. - * @param time Elapsed time. - */ -void _tbStartMotion(int x, int y, int button, int time) { - assert(tb_button != -1); - - tb_tracking = GL_TRUE; - tb_lasttime = time; - _tbPointToVector(x, y, tb_width, tb_height, tb_lastposition); -} - - -/** - * Stops trackball movement. - * @param button Not used - * @param time Not used. - */ -void _tbStopMotion(int button, unsigned time) { - assert(tb_button != -1); - - tb_tracking = GL_FALSE; - - if (time == tb_lasttime && tb_animate) { - glutIdleFunc(_tbAnimate); - } else { - tb_angle = 0.0; - if (tb_animate) { - glutIdleFunc(0); - } - } -} - - - -/** - * Starts or stops the spinning movement of the trackball. - * @param animate GL_TRUE for starting and GL_FALSE for stopping the animation. - */ -void tbAnimate(GLboolean animate) { - tb_animate = animate; -} - - -/** - * Has to be called before any other tb call. - * @param button Mouse button state. - */ -void tbInit(GLuint button) { - tb_button = button; - tb_angle = 0.0; - - /* put the identity in the trackball transform */ - glPushMatrix(); - glLoadIdentity(); - glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) tb_transform); - glPopMatrix(); -} - - -/** - * Gets the tb matrix rotation. - */ -void tbMatrix() { - assert(tb_button != -1); - - glPushMatrix(); - glLoadIdentity(); - glRotatef(tb_angle, -tb_axis[0], tb_axis[2], tb_axis[1]); - glMultMatrixf((GLfloat *) tb_transform); - glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) tb_transform); - glPopMatrix(); - - glMultMatrixf((GLfloat *) tb_transform); -} - - -/** - * Reshape callback function for determining the window size. - * @param width Width of the trackball. - * @param height Height of the trackball. - */ -void tbReshape(int width, int height) { - assert(tb_button != -1); - - tb_width = width; - tb_height = height; -} - - -/** - * Starts motion depending on mouse position and button state. - * @param button The button whose state has changed. - * @param state The state of that button. - * @param x X-position of the mouse pointer. - * @param y Y-position of the mouse pointer. - */ -void tbMouse(int button, int state, int x, int y) { - assert(tb_button != -1); - - if (state == GLUT_DOWN && button == tb_button) - _tbStartMotion(x, y, button, glutGet(GLUT_ELAPSED_TIME)); - else if (state == GLUT_UP && button == tb_button) - _tbStopMotion(button, glutGet(GLUT_ELAPSED_TIME)); -} - - -/** - * Starts a rotating scene motion to the given coordinates. - * @param x The x-coordinate. - * @param y The y-coordinate. - */ -void tbMotion(int x, int y) { - GLfloat current_position[3], dx, dy, dz; - - assert(tb_button != -1); - - if (tb_tracking == GL_FALSE) - return; - - _tbPointToVector(x, y, tb_width, tb_height, current_position); - - /* calculate the angle to rotate by (directly proportional to the - length of the mouse movement */ - dx = current_position[0] - tb_lastposition[0]; - dy = current_position[1] - tb_lastposition[1]; - dz = current_position[2] - tb_lastposition[2]; - tb_angle = 90.0 * sqrt(dx * dx + dy * dy + dz * dz); - - /* calculate the axis of rotation (cross product) */ - tb_axis[0] = tb_lastposition[1] * current_position[2] - - tb_lastposition[2] * current_position[1]; - tb_axis[1] = tb_lastposition[2] * current_position[0] - - tb_lastposition[0] * current_position[2]; - tb_axis[2] = tb_lastposition[0] * current_position[1] - - tb_lastposition[1] * current_position[0]; - - /* reset for next time */ - tb_lasttime = glutGet(GLUT_ELAPSED_TIME); - tb_lastposition[0] = current_position[0]; - tb_lastposition[1] = current_position[1]; - tb_lastposition[2] = current_position[2]; - - /* remember to draw new position */ - glutPostRedisplay(); -} - -/*@}*/ +/** + * \addtogroup unixsimulator + */ +/*@{*/ + +/** + * Simple trackball-like motion adapted (ripped off) from projtex.c + * (written by David Yu and David Blythe). See the SIGGRAPH '96 + * Advanced OpenGL course notes. + * + * + * Usage: + * + * o call tbInit() in before any other tb call + * o call tbReshape() from the reshape callback + * o call tbMatrix() to get the trackball matrix rotation + * o call tbStartMotion() to begin trackball movememt + * o call tbStopMotion() to stop trackball movememt + * o call tbMotion() from the motion callback + * o call tbAnimate(GL_TRUE) if you want the trackball to continue + * spinning after the mouse button has been released + * o call tbAnimate(GL_FALSE) if you want the trackball to stop + * spinning after the mouse button has been released + * + * Typical setup: + * + * + * void + * init(void) + * { + * tbInit(GLUT_MIDDLE_BUTTON); + * tbAnimate(GL_TRUE); + * . . . + * } + * + * void + * reshape(int width, int height) + * { + * tbReshape(width, height); + * . . . + * } + * + * void + * display(void) + * { + * glPushMatrix(); + * + * tbMatrix(); + * . . . draw the scene . . . + * + * glPopMatrix(); + * } + * + * void + * mouse(int button, int state, int x, int y) + * { + * tbMouse(button, state, x, y); + * . . . + * } + * + * void + * motion(int x, int y) + * { + * tbMotion(x, y); + * . . . + * } + * + * int + * main(int argc, char** argv) + * { + * . . . + * init(); + * glutReshapeFunc(reshape); + * glutDisplayFunc(display); + * glutMouseFunc(mouse); + * glutMotionFunc(motion); + * . . . + * } + * + * @file trackball.c + * @brief Helper functions for the UNIX platform Borg simulator. + * @author Martin Ongsiek, David Yu, David Blythe + */ + +/* includes */ +#include +#include +#ifdef OSX_ +# include +#else +# include +#endif +#include "trackball.h" + + +/* globals */ +static GLuint tb_lasttime; +static GLfloat tb_lastposition[3]; + +static GLfloat tb_angle = 0.0; +static GLfloat tb_axis[3]; +static GLfloat tb_transform[4][4]; + +static GLuint tb_width; +static GLuint tb_height; + +static GLint tb_button = -1; +static GLboolean tb_tracking = GL_FALSE; +static GLboolean tb_animate = GL_TRUE; + + +/* functions */ + +/** + * Project x and y onto a hemisphere centered within given width and height. + * @param x X-coordinate + * @param y Y-coordinate + * @param width Width of the hemisphere. + * @param height Width of the hemisphere. + * @param v Vector where the projection is performed on. + */ +static void _tbPointToVector(int x, int y, int width, int height, float v[3]) { + float d, a; + + /* project x, y onto a hemisphere centered within width, height. */ + v[0] = (2.0 * x - width) / width; + v[1] = (height - 2.0 * y) / height; + d = sqrt(v[0] * v[0] + v[1] * v[1]); + v[2] = cos((3.14159265 / 2.0) * ((d < 1.0) ? d : 1.0)); + a = 1.0 / sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); + v[0] *= a; + v[1] *= a; + v[2] *= a; +} + + +/** + * Redisplay current window contents. + */ +static void _tbAnimate(void) { + glutPostRedisplay(); +} + + +/** + * Starts trackball movement depending on the mouse position. + * @param x X-position of the mouse pointer. + * @param y Y-position of the mouse pointer. + * @param button Not used. + * @param time Elapsed time. + */ +void _tbStartMotion(int x, int y, int button, int time) { + assert(tb_button != -1); + + tb_tracking = GL_TRUE; + tb_lasttime = time; + _tbPointToVector(x, y, tb_width, tb_height, tb_lastposition); +} + + +/** + * Stops trackball movement. + * @param button Not used + * @param time Not used. + */ +void _tbStopMotion(int button, unsigned time) { + assert(tb_button != -1); + + tb_tracking = GL_FALSE; + + if (time == tb_lasttime && tb_animate) { + glutIdleFunc(_tbAnimate); + } else { + tb_angle = 0.0; + if (tb_animate) { + glutIdleFunc(0); + } + } +} + + + +/** + * Starts or stops the spinning movement of the trackball. + * @param animate GL_TRUE for starting and GL_FALSE for stopping the animation. + */ +void tbAnimate(GLboolean animate) { + tb_animate = animate; +} + + +/** + * Has to be called before any other tb call. + * @param button Mouse button state. + */ +void tbInit(GLuint button) { + tb_button = button; + tb_angle = 0.0; + + /* put the identity in the trackball transform */ + glPushMatrix(); + glLoadIdentity(); + glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) tb_transform); + glPopMatrix(); +} + + +/** + * Gets the tb matrix rotation. + */ +void tbMatrix() { + assert(tb_button != -1); + + glPushMatrix(); + glLoadIdentity(); + glRotatef(tb_angle, -tb_axis[0], tb_axis[2], tb_axis[1]); + glMultMatrixf((GLfloat *) tb_transform); + glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) tb_transform); + glPopMatrix(); + + glMultMatrixf((GLfloat *) tb_transform); +} + + +/** + * Reshape callback function for determining the window size. + * @param width Width of the trackball. + * @param height Height of the trackball. + */ +void tbReshape(int width, int height) { + assert(tb_button != -1); + + tb_width = width; + tb_height = height; +} + + +/** + * Starts motion depending on mouse position and button state. + * @param button The button whose state has changed. + * @param state The state of that button. + * @param x X-position of the mouse pointer. + * @param y Y-position of the mouse pointer. + */ +void tbMouse(int button, int state, int x, int y) { + assert(tb_button != -1); + + if (state == GLUT_DOWN && button == tb_button) + _tbStartMotion(x, y, button, glutGet(GLUT_ELAPSED_TIME)); + else if (state == GLUT_UP && button == tb_button) + _tbStopMotion(button, glutGet(GLUT_ELAPSED_TIME)); +} + + +/** + * Starts a rotating scene motion to the given coordinates. + * @param x The x-coordinate. + * @param y The y-coordinate. + */ +void tbMotion(int x, int y) { + GLfloat current_position[3], dx, dy, dz; + + assert(tb_button != -1); + + if (tb_tracking == GL_FALSE) + return; + + _tbPointToVector(x, y, tb_width, tb_height, current_position); + + /* calculate the angle to rotate by (directly proportional to the + length of the mouse movement */ + dx = current_position[0] - tb_lastposition[0]; + dy = current_position[1] - tb_lastposition[1]; + dz = current_position[2] - tb_lastposition[2]; + tb_angle = 90.0 * sqrt(dx * dx + dy * dy + dz * dz); + + /* calculate the axis of rotation (cross product) */ + tb_axis[0] = tb_lastposition[1] * current_position[2] + - tb_lastposition[2] * current_position[1]; + tb_axis[1] = tb_lastposition[2] * current_position[0] + - tb_lastposition[0] * current_position[2]; + tb_axis[2] = tb_lastposition[0] * current_position[1] + - tb_lastposition[1] * current_position[0]; + + /* reset for next time */ + tb_lasttime = glutGet(GLUT_ELAPSED_TIME); + tb_lastposition[0] = current_position[0]; + tb_lastposition[1] = current_position[1]; + tb_lastposition[2] = current_position[2]; + + /* remember to draw new position */ + glutPostRedisplay(); +} + +/*@}*/ diff --git a/simulator/trackball.h b/src/simulator/trackball.h similarity index 95% rename from simulator/trackball.h rename to src/simulator/trackball.h index 412068c..34ba4cd 100644 --- a/simulator/trackball.h +++ b/src/simulator/trackball.h @@ -1,99 +1,99 @@ -/** - * \addtogroup unixsimulator - */ -/*@{*/ - -/** - * Simple trackball-like motion adapted (ripped off) from projtex.c - * (written by David Yu and David Blythe). See the SIGGRAPH '96 - * Advanced OpenGL course notes. - * - * - * Usage: - * - * o call tbInit() in before any other tb call - * o call tbReshape() from the reshape callback - * o call tbMatrix() to get the trackball matrix rotation - * o call tbStartMotion() to begin trackball movememt - * o call tbStopMotion() to stop trackball movememt - * o call tbMotion() from the motion callback - * o call tbAnimate(GL_TRUE) if you want the trackball to continue - * spinning after the mouse button has been released - * o call tbAnimate(GL_FALSE) if you want the trackball to stop - * spinning after the mouse button has been released - * - * Typical setup: - * - * - * void - * init(void) - * { - * tbInit(GLUT_MIDDLE_BUTTON); - * tbAnimate(GL_TRUE); - * . . . - * } - * - * void - * reshape(int width, int height) - * { - * tbReshape(width, height); - * . . . - * } - * - * void - * display(void) - * { - * glPushMatrix(); - * - * tbMatrix(); - * . . . draw the scene . . . - * - * glPopMatrix(); - * } - * - * void - * mouse(int button, int state, int x, int y) - * { - * tbMouse(button, state, x, y); - * . . . - * } - * - * void - * motion(int x, int y) - * { - * tbMotion(x, y); - * . . . - * } - * - * int - * main(int argc, char** argv) - * { - * . . . - * init(); - * glutReshapeFunc(reshape); - * glutDisplayFunc(display); - * glutMouseFunc(mouse); - * glutMotionFunc(motion); - * . . . - * } - * - * @file trackball.h - * @brief Header file for helper functions for the UNIX platform Borg simulator. - * @author Martin Ongsiek, David Yu, David Blythe - */ - - - /* functions */ - void tbInit(GLuint button); - - void tbMatrix(void); - - void tbReshape(int width, int height); - - void tbMouse(int button, int state, int x, int y); - - void tbMotion(int x, int y); - - void tbAnimate(GLboolean animate); - - /*@}*/ +/** + * \addtogroup unixsimulator + */ +/*@{*/ + +/** + * Simple trackball-like motion adapted (ripped off) from projtex.c + * (written by David Yu and David Blythe). See the SIGGRAPH '96 + * Advanced OpenGL course notes. + * + * + * Usage: + * + * o call tbInit() in before any other tb call + * o call tbReshape() from the reshape callback + * o call tbMatrix() to get the trackball matrix rotation + * o call tbStartMotion() to begin trackball movememt + * o call tbStopMotion() to stop trackball movememt + * o call tbMotion() from the motion callback + * o call tbAnimate(GL_TRUE) if you want the trackball to continue + * spinning after the mouse button has been released + * o call tbAnimate(GL_FALSE) if you want the trackball to stop + * spinning after the mouse button has been released + * + * Typical setup: + * + * + * void + * init(void) + * { + * tbInit(GLUT_MIDDLE_BUTTON); + * tbAnimate(GL_TRUE); + * . . . + * } + * + * void + * reshape(int width, int height) + * { + * tbReshape(width, height); + * . . . + * } + * + * void + * display(void) + * { + * glPushMatrix(); + * + * tbMatrix(); + * . . . draw the scene . . . + * + * glPopMatrix(); + * } + * + * void + * mouse(int button, int state, int x, int y) + * { + * tbMouse(button, state, x, y); + * . . . + * } + * + * void + * motion(int x, int y) + * { + * tbMotion(x, y); + * . . . + * } + * + * int + * main(int argc, char** argv) + * { + * . . . + * init(); + * glutReshapeFunc(reshape); + * glutDisplayFunc(display); + * glutMouseFunc(mouse); + * glutMotionFunc(motion); + * . . . + * } + * + * @file trackball.h + * @brief Header file for helper functions for the UNIX platform Borg simulator. + * @author Martin Ongsiek, David Yu, David Blythe + */ + + + /* functions */ + void tbInit(GLuint button); + + void tbMatrix(void); + + void tbReshape(int width, int height); + + void tbMouse(int button, int state, int x, int y); + + void tbMotion(int x, int y); + + void tbAnimate(GLboolean animate); + + /*@}*/ diff --git a/simulator/winmain.c b/src/simulator/winmain.c similarity index 81% rename from simulator/winmain.c rename to src/simulator/winmain.c index a10ae7a..c3f67c7 100644 --- a/simulator/winmain.c +++ b/src/simulator/winmain.c @@ -50,23 +50,24 @@ /** Height of the canvas. */ #define WND_Y_EXTENTS (NUM_ROWS * LED_EXTENT) - /* string constants */ LPCSTR g_strWindowClass = "BorgSimulatorWindowClass"; LPCSTR g_strWindowTitle = "Borg Simulator"; -LPCSTR g_strError = "Error"; -LPCSTR g_strErrorRegisterWindow = "Could not register window class."; -LPCSTR g_strErrorCreateWindow = "Could not create window."; -LPCSTR g_strErrorCreateEvent = "Could not create wait event."; -LPCSTR g_strErrorCreateThread = "Could not create display loop thread."; -LPCSTR g_strErrorCreateUITimer = "Could not create UI Timer."; +LPCSTR g_strErr = "Error"; +LPCSTR g_strErrTimerResolution = "Could not retrieve minimum timer resolution."; +LPCSTR g_strErrRegisterWindow = "Could not register window class."; +LPCSTR g_strErrCreateWindow = "Could not create window."; +LPCSTR g_strErrCreateEvent = "Could not create wait event."; +LPCSTR g_strErrCreateThread = "Could not create display loop thread."; +LPCSTR g_strErrCreateUITimer = "Could not create UI Timer."; +/** Minimum timer resolution the system is capable of. */ +UINT g_uResolution; /** Event object for the multimedia timer (wait() function). */ HANDLE g_hWaitEvent; - /** Fake port for simulating joystick input. */ volatile unsigned char fakeport; /** Flag which indicates if wait should jump to the menu if fire is pressed. */ @@ -82,7 +83,6 @@ LRESULT CALLBACK simWndProc(HWND hWnd, WPARAM wParam, LPARAM lParam); - /** * Creates a new window and makes it visible. * @param hInstance Handle of the instance where this window should belong to. @@ -110,7 +110,7 @@ HWND simCreateWindow(HINSTANCE hInstance, if (RegisterClassA(&lpwc) != 0) { /* ensure that the client area has the right proportions */ - RECT rect = {0, 0, WND_X_EXTENTS * 1.5 - 1, WND_Y_EXTENTS * 1.5 - 1}; + RECT rect = {0, 0, WND_X_EXTENTS * 1.5 - 1, WND_Y_EXTENTS * 1.5 - 1}; AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW & ~(WS_OVERLAPPED), FALSE); /* create window and retrieve its handle */ @@ -133,13 +133,12 @@ HWND simCreateWindow(HINSTANCE hInstance, } else { - fprintf(stderr, g_strErrorRegisterWindow); + fprintf(stderr, g_strErrRegisterWindow); } return hWnd; } - /** * Closes windows and unregisters its associated window class. * @param lphWnd Pointer to window handle. @@ -152,7 +151,6 @@ void simDestroyWindow(HWND hWnd, UnregisterClassA(g_strWindowClass, hInstance); } - /** * Draws the LED matrix on the given device context. * @param hdc The device context where the LED matrix should be drawn on. @@ -216,7 +214,6 @@ void simDrawMatrix(HDC hdc) } } - /** * Retrieves device context from given window, creates a compatible memory * device context for double buffering and hands that thing over to @@ -363,7 +360,7 @@ LRESULT CALLBACK simWndProc(HWND hWnd, /* map key releases to fake joystick movements */ case WM_KEYUP: - switch(wParam) + switch (wParam) { case VK_SPACE: /* fire */ fakeport &= ~0x01; @@ -411,7 +408,6 @@ LRESULT CALLBACK simWndProc(HWND hWnd, return lResult; } - /** * Entry point for starting the the display loop in a thread. * @param lpParam Free style arguments for the thread function (not used here). @@ -423,19 +419,36 @@ DWORD WINAPI simLoop(LPVOID lpParam) return 0; } +/** + * Retrieves and enforces the minimum timer resolution of the current system. + * @return Result of the multimedia timer operations. + */ +MMRESULT simSetMinimumTimerResolution() +{ + TIMECAPS tc; + MMRESULT mmresult; + + mmresult = timeGetDevCaps(&tc, sizeof(tc)); + if (mmresult == TIMERR_NOERROR) + { + /* retrieve best resolution and configure timer services accordingly */ + g_uResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax); + mmresult = timeBeginPeriod(g_uResolution); + } + + return mmresult; +} /** * Wait function which utilizes multimedia timers and thread synchronization * objects. Although this is much more complicated than calling the Sleep() * function, it is also much more precise. * @param ms The requested delay in milliseconds. + * @param uResolution The minimum timer resolution the system is capable of. */ void wait(int ms) { - TIMECAPS tc; - MMRESULT mmresult; MMRESULT mmTimerEventId; - UINT uResolution; /* check if fire button is pressed (and if it is, jump to the menu) */ if (waitForFire) @@ -446,35 +459,20 @@ void wait(int ms) } } - /* retrieve timer resolution capabilities of the current system */ - mmresult = timeGetDevCaps(&tc, sizeof(tc)); - if (mmresult == TIMERR_NOERROR) + /* retrieve a multimedia timer */ + mmTimerEventId = timeSetEvent(ms, g_uResolution, g_hWaitEvent, 0, + TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); + if (mmTimerEventId != 0) { - /* retrieve best resolution and configure timer services accordingly */ - uResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax); - mmresult = timeBeginPeriod(uResolution); - if (mmresult == TIMERR_NOERROR) - { - /* actually retrieve a multimedia timer */ - mmTimerEventId = timeSetEvent(ms, uResolution, g_hWaitEvent, 0, - TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); - if (mmTimerEventId != 0) - { - /* now halt until that timer pulses our wait event object */ - WaitForSingleObject(g_hWaitEvent, INFINITE); - ResetEvent(g_hWaitEvent); + /* now halt until that timer pulses our wait event object */ + WaitForSingleObject(g_hWaitEvent, INFINITE); + ResetEvent(g_hWaitEvent); - /* relieve the timer from its duties */ - timeKillEvent(mmTimerEventId); - } - - /* relax timer service constraints */ - timeEndPeriod (uResolution); - } + /* relieve the timer from its duties */ + timeKillEvent(mmTimerEventId); } } - /** * Main function of the windows simulator. * @param hInstance Instance handle given by the operating system. @@ -485,8 +483,8 @@ void wait(int ms) */ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) + LPSTR lpCmdLine, + int nCmdShow) { HWND hWnd; MSG msg; @@ -496,55 +494,67 @@ int APIENTRY WinMain(HINSTANCE hInstance, if ((hWnd = simCreateWindow(hInstance, nCmdShow)) != NULL) { - /* event handle for multimedia timer (for the wait() function) */ - g_hWaitEvent = CreateEventA(NULL, TRUE, FALSE, "Local\\WaitEvent"); - if (g_hWaitEvent != NULL) + /* retrieve minimum timer resolution */ + if (simSetMinimumTimerResolution() == TIMERR_NOERROR) { - /* start the display loop thread */ - hLoopThread = CreateThread(NULL, 0, simLoop, NULL, 0, NULL); - if (hLoopThread != NULL) + /* event handle for multimedia timer (for the wait() function) */ + g_hWaitEvent = CreateEventA(NULL, TRUE, FALSE, "Local\\WaitEvent"); + if (g_hWaitEvent != NULL) { - SetThreadPriority(hLoopThread, THREAD_PRIORITY_TIME_CRITICAL); - - /* issue a UI timer message every 40 ms (roughly 25 fps) */ - uTimerId = SetTimer(hWnd, 23, 40, NULL); - if (uTimerId != 0) + /* start the display loop thread */ + hLoopThread = CreateThread(NULL, 0, simLoop, NULL, 0, NULL); + if (hLoopThread != NULL) { - /* standard Windows(R) message loop */ - while (GetMessageA(&msg, NULL, 0, 0)) - { - TranslateMessage(&msg); - DispatchMessageA(&msg); - } - nExitCode = msg.wParam; + SetThreadPriority(hLoopThread, + THREAD_PRIORITY_TIME_CRITICAL); - KillTimer(hWnd, uTimerId); + /* issue a UI timer message every 40 ms (roughly 25 fps) */ + uTimerId = SetTimer(hWnd, 23, 40, NULL); + if (uTimerId != 0) + { + /* standard Windows(R) message loop */ + while (GetMessageA(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + nExitCode = msg.wParam; + + KillTimer(hWnd, uTimerId); + } + else + { + fprintf(stderr, g_strErrCreateUITimer); + } + + TerminateThread(hLoopThread, 0); } else { - fprintf(stderr, g_strErrorCreateUITimer); + fprintf(stderr, g_strErrCreateThread); } - TerminateThread(hLoopThread, 0); + /* relieve wait event object from its duties */ + CloseHandle(g_hWaitEvent); } else { - fprintf(stderr, g_strErrorCreateThread); + fprintf(stderr, g_strErrCreateEvent); } - /* relieve wait event object from its duties */ - CloseHandle(g_hWaitEvent); + /* relieve timer resolution constraints */ + timeEndPeriod(g_uResolution); } else { - fprintf(stderr, g_strErrorCreateEvent); + fprintf(stderr, g_strErrTimerResolution); } simDestroyWindow(hWnd, hInstance); } else { - fprintf(stderr, g_strErrorCreateWindow); + fprintf(stderr, g_strErrCreateWindow); } return nExitCode; diff --git a/smallani/Makefile b/src/smallani/Makefile similarity index 70% rename from smallani/Makefile rename to src/smallani/Makefile index a7f5c00..eb3c91c 100644 --- a/smallani/Makefile +++ b/src/smallani/Makefile @@ -1,7 +1,8 @@ -TARGET = libsmallanimations.a -TOPDIR = .. +MAKETOPDIR = ../.. -include $(TOPDIR)/defaults.mk +TARGET = libsmallanimations.a + +include $(MAKETOPDIR)/defaults.mk ifeq ($(SMALLANIMATION_ROWWALK),y) SRC += rowwalk.c @@ -19,4 +20,6 @@ ifeq ($(SMALLANIMATION_COLBOUNCE),y) endif -include $(TOPDIR)/rules.mk +include $(MAKETOPDIR)/rules.mk + +include $(MAKETOPDIR)/depend.mk diff --git a/smallani/colbounce.c b/src/smallani/colbounce.c similarity index 100% rename from smallani/colbounce.c rename to src/smallani/colbounce.c diff --git a/smallani/rowbounce.h b/src/smallani/colbounce.h similarity index 100% rename from smallani/rowbounce.h rename to src/smallani/colbounce.h diff --git a/smallani/colwalk.c b/src/smallani/colwalk.c similarity index 100% rename from smallani/colwalk.c rename to src/smallani/colwalk.c diff --git a/smallani/colwalk.h b/src/smallani/colwalk.h similarity index 100% rename from smallani/colwalk.h rename to src/smallani/colwalk.h diff --git a/smallani/config.in b/src/smallani/config.in similarity index 100% rename from smallani/config.in rename to src/smallani/config.in diff --git a/smallani/rowbounce.c b/src/smallani/rowbounce.c similarity index 100% rename from smallani/rowbounce.c rename to src/smallani/rowbounce.c diff --git a/smallani/colbounce.h b/src/smallani/rowbounce.h similarity index 60% rename from smallani/colbounce.h rename to src/smallani/rowbounce.h index 2f19a3b..396bbda 100644 --- a/smallani/colbounce.h +++ b/src/smallani/rowbounce.h @@ -1,6 +1,6 @@ #ifndef ROWBOUNCE_H_ #define ROWBOUNCE_H_ -void rowbounce(uint8_t times,uint8_t speed); +void rowbounce(uint8_t times, uint8_t speed); #endif /* ROWBOUNCE_H_ */ diff --git a/smallani/rowwalk.c b/src/smallani/rowwalk.c similarity index 100% rename from smallani/rowwalk.c rename to src/smallani/rowwalk.c diff --git a/smallani/rowwalk.h b/src/smallani/rowwalk.h similarity index 100% rename from smallani/rowwalk.h rename to src/smallani/rowwalk.h diff --git a/uart/uart.c b/src/uart/uart.c similarity index 100% rename from uart/uart.c rename to src/uart/uart.c diff --git a/uart/uart.h b/src/uart/uart.h similarity index 100% rename from uart/uart.h rename to src/uart/uart.h diff --git a/util.c b/src/util.c similarity index 94% rename from util.c rename to src/util.c index 6c52e98..0629b68 100644 --- a/util.c +++ b/src/util.c @@ -60,7 +60,7 @@ void wait(int ms){ } #endif -#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || defined (__AVR_ATmega328__) +#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || defined (__AVR_ATmega328__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__) while(!(TIFR1&(1<