Game and menu support added. Dependencies fixed. Compiles fine for AVR and Windows. Linux simulator is still missing a linker script.
This commit is contained in:
parent
ce5ac2ef9a
commit
44e84677e7
3
Makefile
3
Makefile
|
@ -40,7 +40,6 @@ include defaults.mk
|
|||
@ echo "checking in which subdirs to build"
|
||||
@ $(RM) -f $@
|
||||
@ echo "SUBDIRS += animations" >> $@
|
||||
# @ echo "SUBDIRS += animations games menu" >> $@
|
||||
@ (for subdir in `grep -e "^#define .*_SUPPORT" autoconf.h \
|
||||
| sed -e "s/^#define //" -e "s/_SUPPORT.*//" \
|
||||
| tr "[A-Z]\\n" "[a-z] " `; do \
|
||||
|
@ -54,12 +53,14 @@ ifneq ($(MAKECMDGOALS),menuconfig)
|
|||
|
||||
include $(TOPDIR)/.subdirs
|
||||
include $(TOPDIR)/.config
|
||||
include $(TOPDIR)/games/games.mk
|
||||
|
||||
endif # MAKECMDGOALS!=menuconfig
|
||||
endif # MAKECMDGOALS!=mrproper
|
||||
endif # MAKECMDGOALS!=clean
|
||||
endif # no_deps!=t
|
||||
|
||||
|
||||
##############################################################################
|
||||
|
||||
SUBDIRS_AVR = borg_hw
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "../util.h"
|
||||
#include "../random/prng.h"
|
||||
#include "snake.h"
|
||||
#include "../joystick.h"
|
||||
|
||||
#define RANDOM8() (random8())
|
||||
|
||||
|
|
4
avr5.x
4
avr5.x
|
@ -154,9 +154,9 @@ SECTIONS
|
|||
*(.rodata) /* We need to include .rodata here if gcc is used */
|
||||
*(.rodata*) /* with -fdata-sections. */
|
||||
*(.gnu.linkonce.d*)
|
||||
__game_descriptors_start__ = . ;
|
||||
PROVIDE (_game_descriptors_start__ = .) ;
|
||||
*(.game_descriptors)
|
||||
__game_descriptors_end__ = . ;
|
||||
PROVIDE (_game_descriptors_end__ = .) ;
|
||||
. = ALIGN(2);
|
||||
_edata = . ;
|
||||
PROVIDE (__data_end = .) ;
|
||||
|
|
27
config.in
27
config.in
|
@ -20,20 +20,37 @@ comment "General Setup"
|
|||
endmenu
|
||||
###############################################################################
|
||||
|
||||
|
||||
###################### Borg Hardware Menu #####################################
|
||||
source borg_hw/config.in
|
||||
###############################################################################
|
||||
|
||||
|
||||
########################### Features Menu #####################################
|
||||
mainmenu_option next_comment
|
||||
comment "Features"
|
||||
|
||||
bool "prng random number generator" RANDOM_SUPPORT y
|
||||
|
||||
endmenu
|
||||
###############################################################################
|
||||
|
||||
|
||||
########################## Scrolltext Menu ####################################
|
||||
source scrolltext/config.in
|
||||
###############################################################################
|
||||
|
||||
|
||||
############################ Joystick Menu ####################################
|
||||
source joystick/config.in
|
||||
###############################################################################
|
||||
|
||||
dep_bool "menu support" MENU_SUPPORT $JOYSTICK_SUPPORT
|
||||
|
||||
############################ Game Menu ########################################
|
||||
source games/config.in
|
||||
###############################################################################
|
||||
|
||||
|
||||
######################### Animations Menu #####################################
|
||||
mainmenu_option next_comment
|
||||
|
@ -43,12 +60,12 @@ comment "Animations"
|
|||
dep_bool "Scrolltext" ANIMATION_SCROLLTEXT $SCROLLTEXT_SUPPORT
|
||||
bool "Spirale" ANIMATION_SPIRALE
|
||||
bool "Joern1" ANIMATION_JOERN1
|
||||
bool "Snake" ANIMATION_SNAKE
|
||||
dep_bool "Snake" ANIMATION_SNAKE $RANDOM_SUPPORT
|
||||
bool "Schachbrett" ANIMATION_SCHACHBRETT
|
||||
bool "Feuer" ANIMATION_FEUER
|
||||
bool "Matrix" ANIMATION_MATRIX
|
||||
bool "Random bright" ANIMATION_RANDOM_BRIGHT
|
||||
bool "Game of Life" ANIMATION_GAMEOFLIFE
|
||||
dep_bool "Feuer" ANIMATION_FEUER $RANDOM_SUPPORT
|
||||
dep_bool "Matrix" ANIMATION_MATRIX $RANDOM_SUPPORT
|
||||
dep_bool "Random bright" ANIMATION_RANDOM_BRIGHT $RANDOM_SUPPORT
|
||||
dep_bool "Game of Life" ANIMATION_GAMEOFLIFE $RANDOM_SUPPORT
|
||||
|
||||
comment "Special Animations"
|
||||
bool "Test Animations" ANIMATION_TESTS
|
||||
|
|
|
@ -22,7 +22,7 @@ CFLAGS ?= -Wall -W -Wno-unused-parameter -Wno-sign-compare
|
|||
CFLAGS += -g -Os -std=gnu99 -fgnu89-inline
|
||||
|
||||
# flags for the linker
|
||||
LDFLAGS += -mmcu=$(MCU) -T avr5.x
|
||||
LDFLAGS += -T ./avr5.x -mmcu=$(MCU)
|
||||
|
||||
|
||||
#############################################################################
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "mcuf/mcuf.h"
|
||||
#include "menu/menu.h"
|
||||
#include "pixel.h"
|
||||
#include "joystick.h"
|
||||
#include "joystick/joystick.h"
|
||||
|
||||
|
||||
volatile unsigned char oldMode, oldOldmode, mode;
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
TARGET = libanimations.a
|
||||
TOPDIR = ..
|
||||
|
||||
include $(TOPDIR)/defaults.mk
|
||||
|
||||
|
||||
#ifeq ($(GAME_SNAKE),y)
|
||||
SRC += snake_game.c
|
||||
#endif
|
||||
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
|
@ -0,0 +1,9 @@
|
|||
mainmenu_option next_comment
|
||||
comment "Games"
|
||||
|
||||
dep_bool "tetris" GAME_TETRIS $JOYSTICK_SUPPORT $RANDOM_SUPPORT
|
||||
dep_bool "space invaders" GAME_SPACE_INVADERS $JOYSTICK_SUPPORT $RANDOM_SUPPORT
|
||||
dep_bool "snake" GAME_SNAKE $JOYSTICK_SUPPORT $RANDOM_SUPPORT
|
||||
|
||||
|
||||
endmenu
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
ifeq ($(GAME_TETRIS),y)
|
||||
SUBDIRS += games/tetris
|
||||
endif
|
||||
|
||||
ifeq ($(GAME_SPACE_INVADERS),y)
|
||||
SUBDIRS += games/space_invaders
|
||||
endif
|
||||
|
||||
ifeq ($(GAME_SNAKE),y)
|
||||
SUBDIRS += games/snake
|
||||
endif
|
|
@ -0,0 +1,8 @@
|
|||
TARGET =
|
||||
TOPDIR = ../..
|
||||
|
||||
include $(TOPDIR)/defaults.mk
|
||||
|
||||
SRC = snake_game.c
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
#include "../config.h"
|
||||
#include "../compat/pgmspace.h"
|
||||
#include "../menu/menu.h"
|
||||
#include "../pixel.h"
|
||||
#include "../random/prng.h"
|
||||
#include "../util.h"
|
||||
#include "../joystick.h"
|
||||
#include "../../config.h"
|
||||
#include "../../compat/pgmspace.h"
|
||||
#include "../../menu/menu.h"
|
||||
#include "../../pixel.h"
|
||||
#include "../../random/prng.h"
|
||||
#include "../../util.h"
|
||||
#include "../../joystick/joystick.h"
|
||||
|
||||
// MSB is leftmost pixel
|
||||
static uint8_t icon[8] PROGMEM =
|
|
@ -0,0 +1,8 @@
|
|||
TARGET =
|
||||
TOPDIR = ../..
|
||||
|
||||
include $(TOPDIR)/defaults.mk
|
||||
|
||||
SRC = invader_init.c invader_draw.c invader_proc.c invaders2.c
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
|
@ -1,5 +1,7 @@
|
|||
#include <stdlib.h>
|
||||
#include "prng.h"
|
||||
#include "../../config.h"
|
||||
#include "../../joystick/joystick.h"
|
||||
#include "../../random/prng.h"
|
||||
#include "invaders2.h"
|
||||
|
||||
void procCannon(Cannon * cn, uPixel * shot)
|
|
@ -1,12 +1,24 @@
|
|||
#include <stdio.h>
|
||||
#include "util.h"
|
||||
#include "../../util.h"
|
||||
#include "../../compat/eeprom.h"
|
||||
#include "../../compat/pgmspace.h"
|
||||
#include "../../menu/menu.h"
|
||||
#include "../../scrolltext/scrolltext.h"
|
||||
#include "invaders2.h"
|
||||
|
||||
//#include <stdio.h>
|
||||
|
||||
#ifndef __AVR__
|
||||
#define wait(_X) myWait(_X)
|
||||
#endif
|
||||
// MSB is leftmost pixel
|
||||
static uint8_t icon[8] PROGMEM =
|
||||
{0x66, 0x18, 0x3c, 0x5a, 0xff, 0xbd, 0xa5, 0x18}; // Invaders icon
|
||||
|
||||
void borg_invaders();
|
||||
|
||||
game_descriptor_t invaders_game_descriptor __attribute__((section(".game_descriptors"))) ={
|
||||
&borg_invaders,
|
||||
icon,
|
||||
};
|
||||
|
||||
|
||||
void borg_invaders()
|
||||
{
|
||||
|
@ -118,9 +130,11 @@ void borg_invaders()
|
|||
|
||||
clearScreen ();
|
||||
//wait(5000);
|
||||
#ifdef SCROLLTEXT_SUPPORT
|
||||
char text[64];
|
||||
snprintf(text, 64, "</#points: %u", pl.points);
|
||||
scrolltext(text);
|
||||
#endif
|
||||
//printf("scores: %d\n", pl.points);
|
||||
|
||||
|
|
@ -9,14 +9,12 @@
|
|||
|
||||
#ifndef INVADERS2_H
|
||||
#define INVADERS2_H
|
||||
|
||||
#define USE_ORIGINAL_PIXEL_API
|
||||
|
||||
/*CONNECTION TO SIMULATOR*/
|
||||
//extern char fkey;
|
||||
|
||||
/* TEST PARTS NEW API */
|
||||
|
||||
#include "../../config.h"
|
||||
#include "../../pixel.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
signed char x;
|
||||
|
@ -29,11 +27,10 @@ typedef struct
|
|||
unsigned char y;
|
||||
} uPixel;
|
||||
|
||||
//for compatibility to pisel.h api!
|
||||
#define USE_ORIGINAL_PIXEL_API
|
||||
|
||||
//for compatibility to pixel.h api!
|
||||
#ifdef USE_ORIGINAL_PIXEL_API
|
||||
#include "pixel.h"
|
||||
#include "scrolltext.h"
|
||||
#include "joystick.h"
|
||||
|
||||
//typedef uPixel pixel;
|
||||
#define uPixel pixel
|
|
@ -1,25 +1,8 @@
|
|||
LD = avr-ld
|
||||
TARGET =
|
||||
TOPDIR = ../..
|
||||
|
||||
all: tetris.o
|
||||
include $(TOPDIR)/defaults.mk
|
||||
|
||||
tetris.o: piece.o playfield.o view.o logic.o input.o
|
||||
$(LD) -r piece.o playfield.o view.o logic.o input.o -o tetris.o
|
||||
SRC = piece.c playfield.c view.c logic.c input.c
|
||||
|
||||
piece.o: piece.c piece.h
|
||||
$(MCU_CC) $(CFLAGS) -c piece.c -o piece.o
|
||||
|
||||
playfield.o: playfield.c playfield.h piece.h
|
||||
$(MCU_CC) $(CFLAGS) -c playfield.c -o playfield.o
|
||||
|
||||
view.o: view.c view.h logic.h piece.h playfield.h ../config.h ../pixel.h \
|
||||
../util.h ../scrolltext.h
|
||||
$(MCU_CC) $(CFLAGS) -c view.c -o view.o
|
||||
|
||||
logic.o: logic.c logic.h piece.h playfield.h input.h view.h
|
||||
$(MCU_CC) $(CFLAGS) -c logic.c -o logic.o
|
||||
|
||||
input.o: input.c input.h ../joystick.h ../util.h
|
||||
$(MCU_CC) $(CFLAGS) -c input.c -o input.o
|
||||
|
||||
clean:
|
||||
rm -rf *.o *.d
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
|
|
@ -2,23 +2,14 @@
|
|||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <assert.h>
|
||||
#include "../joystick.h"
|
||||
#include "../util.h"
|
||||
#include "../../config.h"
|
||||
#include "../../joystick/joystick.h"
|
||||
#include "../../util.h"
|
||||
#include "input.h"
|
||||
|
||||
/* - the API simulator and the real API have different named wait functions
|
||||
* - the macro PM helps in reading values from PROGMEM on the AVR arch
|
||||
*/
|
||||
#ifdef __AVR__
|
||||
#include <avr/pgmspace.h>
|
||||
#include "../../compat/pgmspace.h"
|
||||
#define WAIT(ms) wait(ms)
|
||||
#define PM(value) pgm_read_word(&value)
|
||||
#else
|
||||
#define PROGMEM
|
||||
#define WAIT(ms) myWait(ms)
|
||||
#define PM(value) (value)
|
||||
#endif
|
||||
|
||||
|
||||
/***********
|
||||
* defines *
|
||||
|
@ -70,7 +61,7 @@ void tetris_input_chatterProtect (tetris_input_t *pIn,
|
|||
|
||||
// amount of loop cycles a command is ignored after its button has been
|
||||
// released (every command has its own counter)
|
||||
const static uint8_t nInitialIgnoreValue[TETRIS_INCMD_NONE] PROGMEM =
|
||||
static const uint8_t nInitialIgnoreValue[TETRIS_INCMD_NONE] PROGMEM =
|
||||
{
|
||||
TETRIS_INPUT_CHATTER_TICKS_ROT_CW,
|
||||
TETRIS_INPUT_CHATTER_TICKS_ROT_CCW,
|
||||
|
|
|
@ -8,17 +8,16 @@
|
|||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/interrupt.h>
|
||||
#endif
|
||||
#include "../../compat/eeprom.h"
|
||||
#include "../../compat/pgmspace.h"
|
||||
#include "../../menu/menu.h"
|
||||
|
||||
#include "logic.h"
|
||||
#include "piece.h"
|
||||
#include "playfield.h"
|
||||
#include "view.h"
|
||||
#include "input.h"
|
||||
#include "../prng.h"
|
||||
#include "../../random/prng.h"
|
||||
|
||||
|
||||
#ifdef EEMEM
|
||||
|
@ -29,6 +28,18 @@
|
|||
uint16_t tetris_logic_nHighscore EEMEM;
|
||||
#endif
|
||||
|
||||
// MSB is leftmost pixel
|
||||
static uint8_t icon[8] PROGMEM =
|
||||
{0x0f, 0x0f, 0xc3, 0xdb, 0xdb, 0xc3, 0xf0, 0xf0}; // Tetris icon
|
||||
|
||||
void tetris();
|
||||
|
||||
game_descriptor_t tetris_game_descriptor __attribute__((section(".game_descriptors"))) ={
|
||||
&tetris,
|
||||
icon,
|
||||
};
|
||||
|
||||
|
||||
/***************************
|
||||
* non-interface functions *
|
||||
***************************/
|
||||
|
|
|
@ -3,22 +3,16 @@
|
|||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include "../config.h"
|
||||
#include "../pixel.h"
|
||||
#include "../util.h"
|
||||
#include "../scrolltext.h"
|
||||
#include "../../config.h"
|
||||
#include "../../pixel.h"
|
||||
#include "../../util.h"
|
||||
#include "../../scrolltext/scrolltext.h"
|
||||
#include "logic.h"
|
||||
#include "piece.h"
|
||||
#include "playfield.h"
|
||||
#include "view.h"
|
||||
|
||||
/* the API simulator and the real API have different named wait functions */
|
||||
#ifdef __AVR__
|
||||
#define WAIT(ms) wait(ms)
|
||||
#else
|
||||
#define WAIT(ms) myWait(ms)
|
||||
#endif
|
||||
|
||||
|
||||
/***********
|
||||
* defines *
|
||||
|
@ -416,6 +410,8 @@ void tetris_view_showResults(tetris_view_t *pV)
|
|||
"</#Lines %u New Highscore %u", nLines, nScore);
|
||||
}
|
||||
|
||||
#ifdef SCROLLTEXT_SUPPORT
|
||||
scrolltext(pszResults);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
13
joystick.c
13
joystick.c
|
@ -1,13 +0,0 @@
|
|||
#include "joystick.h"
|
||||
#include <avr/io.h>
|
||||
|
||||
unsigned char waitForFire;
|
||||
|
||||
|
||||
inline void joy_init(){
|
||||
DDRB &= ~((1<<BITUP)|(1<<BITDOWN)|(1<<BITLEFT)|(1<<BITRIGHT));
|
||||
PORTB |= (1<<BITUP)|(1<<BITDOWN)|(1<<BITLEFT)|(1<<BITRIGHT);
|
||||
|
||||
DDRD &= ~(1<<BITFIRE);
|
||||
PORTD |= (1<<BITFIRE);
|
||||
}
|
33
joystick.h
33
joystick.h
|
@ -1,33 +0,0 @@
|
|||
#ifndef JOYSTICK_H
|
||||
#define JOYSTICK_H
|
||||
|
||||
extern unsigned char waitForFire;
|
||||
void joy_init();
|
||||
|
||||
#ifdef AVR
|
||||
|
||||
#define BITFIRE PD3
|
||||
#define BITRIGHT PB3
|
||||
#define BITLEFT PB2
|
||||
#define BITDOWN PB1
|
||||
#define BITUP PB0
|
||||
|
||||
#define JOYISFIRE (!(PIND & (1<<BITFIRE)))
|
||||
#define JOYISLEFT (!(PINB & (1<<BITLEFT)))
|
||||
#define JOYISRIGHT (!(PINB & (1<<BITRIGHT)))
|
||||
#define JOYISDOWN (!(PINB & (1<<BITDOWN)))
|
||||
#define JOYISUP (!(PINB & (1<<BITUP)))
|
||||
|
||||
#else
|
||||
|
||||
extern unsigned char fakeport;
|
||||
|
||||
#define JOYISFIRE (0x01 & fakeport)
|
||||
#define JOYISLEFT (0x02 & fakeport)
|
||||
#define JOYISRIGHT (0x04 & fakeport)
|
||||
#define JOYISDOWN (0x08 & fakeport)
|
||||
#define JOYISUP (0x10 & fakeport)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // JOYSTICK_H
|
|
@ -0,0 +1,9 @@
|
|||
TARGET =
|
||||
TOPDIR = ..
|
||||
|
||||
include $(TOPDIR)/defaults.mk
|
||||
|
||||
SRC = joystick.c
|
||||
SRC_SIM =
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
|
@ -0,0 +1,101 @@
|
|||
dep_bool_menu "joystick support" JOYSTICK_SUPPORT y
|
||||
|
||||
###################### Parallel joystick menu #################################
|
||||
dep_bool_menu "parallel joystick support" PARALLEL_JOYSTICK_SUPPORT y
|
||||
|
||||
choice 'Pin up' \
|
||||
"PINA PINA \
|
||||
PINB PINB \
|
||||
PINC PINC \
|
||||
PIND PIND" \
|
||||
'PINB' JOYSTICK_PIN_UP
|
||||
|
||||
choice 'Bit up' \
|
||||
"Bit0 0 \
|
||||
Bit1 1 \
|
||||
Bit2 2 \
|
||||
Bit3 3 \
|
||||
Bit4 4 \
|
||||
Bit5 5 \
|
||||
Bit6 6 \
|
||||
Bit7 7" \
|
||||
'Bit0' JOYSTICK_BIT_UP
|
||||
|
||||
choice 'Pin down' \
|
||||
"PINA PINA \
|
||||
PINB PINB \
|
||||
PINC PINC \
|
||||
PIND PIND" \
|
||||
'PINB' JOYSTICK_PIN_DOWN
|
||||
|
||||
choice 'Bit down' \
|
||||
"Bit0 0 \
|
||||
Bit1 1 \
|
||||
Bit2 2 \
|
||||
Bit3 3 \
|
||||
Bit4 4 \
|
||||
Bit5 5 \
|
||||
Bit6 6 \
|
||||
Bit7 7" \
|
||||
'Bit1' JOYSTICK_BIT_DOWN
|
||||
|
||||
choice 'Pin left' \
|
||||
"PINA PINA \
|
||||
PINB PINB \
|
||||
PINC PINC \
|
||||
PIND PIND" \
|
||||
'PINB' JOYSTICK_PIN_LEFT
|
||||
|
||||
choice 'Bit left' \
|
||||
"Bit0 0 \
|
||||
Bit1 1 \
|
||||
Bit2 2 \
|
||||
Bit3 3 \
|
||||
Bit4 4 \
|
||||
Bit5 5 \
|
||||
Bit6 6 \
|
||||
Bit7 7" \
|
||||
'Bit2' JOYSTICK_BIT_LEFT
|
||||
|
||||
choice 'Pin right' \
|
||||
"PINA PINA \
|
||||
PINB PINB \
|
||||
PINC PINC \
|
||||
PIND PIND" \
|
||||
'PINB' JOYSTICK_PIN_RIGHT
|
||||
|
||||
choice 'Bit right' \
|
||||
"Bit0 0 \
|
||||
Bit1 1 \
|
||||
Bit2 2 \
|
||||
Bit3 3 \
|
||||
Bit4 4 \
|
||||
Bit5 5 \
|
||||
Bit6 6 \
|
||||
Bit7 7" \
|
||||
'Bit3' JOYSTICK_BIT_RIGHT
|
||||
|
||||
choice 'Pin fire' \
|
||||
"PINA PINA \
|
||||
PINB PINB \
|
||||
PINC PINC \
|
||||
PIND PIND" \
|
||||
'PIND' JOYSTICK_PIN_FIRE
|
||||
|
||||
choice 'Bit fire' \
|
||||
"Bit0 0 \
|
||||
Bit1 1 \
|
||||
Bit2 2 \
|
||||
Bit3 3 \
|
||||
Bit4 4 \
|
||||
Bit5 5 \
|
||||
Bit6 6 \
|
||||
Bit7 7" \
|
||||
'Bit3' JOYSTICK_BIT_FIRE
|
||||
|
||||
endmenu
|
||||
###############################################################################
|
||||
|
||||
|
||||
|
||||
endmenu
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
#include "../config.h"
|
||||
#include "../makros.h"
|
||||
#include "joystick.h"
|
||||
#include <avr/io.h>
|
||||
|
||||
unsigned char waitForFire;
|
||||
|
||||
|
||||
inline void joy_init(){
|
||||
PORT_FROM_PIN(JOYSTICK_PIN_UP ) |= (1<<JOYSTICK_BIT_UP );
|
||||
PORT_FROM_PIN(JOYSTICK_PIN_DOWN ) |= (1<<JOYSTICK_BIT_DOWN );
|
||||
PORT_FROM_PIN(JOYSTICK_PIN_LEFT ) |= (1<<JOYSTICK_BIT_LEFT );
|
||||
PORT_FROM_PIN(JOYSTICK_PIN_RIGHT) |= (1<<JOYSTICK_BIT_RIGHT);
|
||||
PORT_FROM_PIN(JOYSTICK_PIN_FIRE ) |= (1<<JOYSTICK_BIT_FIRE );
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef JOYSTICK_H
|
||||
#define JOYSTICK_H
|
||||
|
||||
extern unsigned char waitForFire;
|
||||
void joy_init();
|
||||
|
||||
#ifdef AVR
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
#define JOYISUP (!(JOYSTICK_PIN_UP & (1<<JOYSTICK_BIT_UP )))
|
||||
#define JOYISDOWN (!(JOYSTICK_PIN_DOWN & (1<<JOYSTICK_BIT_DOWN )))
|
||||
#define JOYISLEFT (!(JOYSTICK_PIN_LEFT & (1<<JOYSTICK_BIT_LEFT )))
|
||||
#define JOYISRIGHT (!(JOYSTICK_PIN_RIGHT & (1<<JOYSTICK_BIT_RIGHT)))
|
||||
#define JOYISFIRE (!(JOYSTICK_PIN_FIRE & (1<<JOYSTICK_BIT_FIRE )))
|
||||
|
||||
#else
|
||||
|
||||
extern unsigned char fakeport;
|
||||
|
||||
#define JOYISUP (0x10 & fakeport)
|
||||
#define JOYISDOWN (0x08 & fakeport)
|
||||
#define JOYISLEFT (0x02 & fakeport)
|
||||
#define JOYISRIGHT (0x04 & fakeport)
|
||||
#define JOYISFIRE (0x01 & fakeport)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // JOYSTICK_H
|
5
main.c
5
main.c
|
@ -9,6 +9,11 @@
|
|||
#include "random/prng.h"
|
||||
#include "random/persistentCounter.h"
|
||||
#include "display_loop.h"
|
||||
#include "pixel.h"
|
||||
|
||||
#ifdef JOYSTICK_SUPPORT
|
||||
#include "joystick/joystick.h"
|
||||
#endif
|
||||
|
||||
int main (void){
|
||||
clear_screen(0);
|
||||
|
|
4
makros.h
4
makros.h
|
@ -1,2 +1,6 @@
|
|||
|
||||
#define DDR(port) (*(volatile uint8_t*)((&port)-1))
|
||||
|
||||
#define DDR_FROM_PIN(pin) (*(volatile uint8_t*)((&pin)+1))
|
||||
|
||||
#define PORT_FROM_PIN(pin) (*(volatile uint8_t*)((&pin)+2))
|
||||
|
|
17
menu/menu.c
17
menu/menu.c
|
@ -14,14 +14,14 @@
|
|||
#include "../config.h"
|
||||
#include "../util.h"
|
||||
#include "../pixel.h"
|
||||
#include "../joystick.h"
|
||||
#include "../joystick/joystick.h"
|
||||
|
||||
|
||||
extern game_descriptor_t _game_descriptors_start__[];
|
||||
extern game_descriptor_t _game_descriptors_end__[];
|
||||
|
||||
// defines
|
||||
#define MENU_ITEM_MAX (((int)_game_descriptors_end__ - (int)_game_descriptors_start__)/sizeof(game_descriptor_t))
|
||||
#define MENU_ITEM_MAX (((unsigned int)_game_descriptors_end__ - (unsigned int)_game_descriptors_start__)/sizeof(game_descriptor_t))
|
||||
|
||||
#define MENU_WIDTH_ICON 8
|
||||
#define MENU_HEIGHT_ICON 8
|
||||
|
@ -48,6 +48,8 @@ void menu()
|
|||
wait(MENU_POLL_INTERVAL);
|
||||
}
|
||||
|
||||
if(MENU_ITEM_MAX == 0) goto end;
|
||||
|
||||
// set initial menu item
|
||||
static uint8_t miSelection = 0;
|
||||
// scroll in currently selected menu item
|
||||
|
@ -102,6 +104,7 @@ void menu()
|
|||
}
|
||||
}
|
||||
|
||||
end:
|
||||
waitForFire = 1;
|
||||
return;
|
||||
}
|
||||
|
@ -109,16 +112,6 @@ void menu()
|
|||
|
||||
uint8_t menu_getIconPixel(uint8_t item, int8_t x, int8_t y)
|
||||
{
|
||||
/*
|
||||
|
||||
// MSB is leftmost pixel
|
||||
static uint8_t nIcon[][8] PROGMEM =
|
||||
{{0xff, 0x81, 0xbd, 0xa5, 0xa5, 0xad, 0xa1, 0xbf}, // Snake icon
|
||||
{0x66, 0x18, 0x3c, 0x5a, 0xff, 0xbd, 0xa5, 0x18}, // Invaders icon
|
||||
{0x0f, 0x0f, 0xc3, 0xdb, 0xdb, 0xc3, 0xf0, 0xf0}}; // Tetris icon
|
||||
|
||||
*/
|
||||
|
||||
// is x within the icon or do we have reached the delimiter?
|
||||
if (x < MENU_WIDTH_ICON)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#
|
||||
# Automatically generated by make menuconfig: don't edit
|
||||
#
|
||||
|
||||
#
|
||||
# General Setup
|
||||
#
|
||||
MCU=atmega32
|
||||
FREQ=16000000
|
||||
|
||||
#
|
||||
# Borg Hardware
|
||||
#
|
||||
NUM_ROWS=16
|
||||
NUM_COLS=16
|
||||
NUMPLANE=3
|
||||
BORG_HW=HW_BORG_16
|
||||
|
||||
#
|
||||
# Borg16 port setup
|
||||
#
|
||||
COLPORT1=PORTC
|
||||
COLPORT2=PORTA
|
||||
ROWPORT=PORTD
|
||||
PIN_MCLR=4
|
||||
PIN_CLK=6
|
||||
PIN_DATA=7
|
||||
# REVERSE_COLS is not set
|
||||
# INVERT_ROWS is not set
|
||||
# INTERLACED_ROWS is not set
|
||||
# INTERLACED_COLS is not set
|
||||
|
||||
#
|
||||
# Features
|
||||
#
|
||||
RANDOM_SUPPORT=y
|
||||
SCROLLTEXT_SUPPORT=y
|
||||
SCROLLTEXT_FONT=font_arial8
|
||||
SCROLLTEXT_BUFFER_SIZE=128
|
||||
SCROLL_X_SPEED=20
|
||||
SCROLL_Y_SPEED=20
|
||||
SCROLLTEXT_TEXT="</#www.das-labor.org"
|
||||
JOYSTICK_SUPPORT=y
|
||||
PARALLEL_JOYSTICK_SUPPORT=y
|
||||
JOYSTICK_PIN_UP=PINB
|
||||
JOYSTICK_BIT_UP=0
|
||||
JOYSTICK_PIN_DOWN=PINB
|
||||
JOYSTICK_BIT_DOWN=1
|
||||
JOYSTICK_PIN_LEFT=PINB
|
||||
JOYSTICK_BIT_LEFT=2
|
||||
JOYSTICK_PIN_RIGHT=PINB
|
||||
JOYSTICK_BIT_RIGHT=3
|
||||
JOYSTICK_PIN_FIRE=PIND
|
||||
JOYSTICK_BIT_FIRE=3
|
||||
MENU_SUPPORT=y
|
||||
|
||||
#
|
||||
# Games
|
||||
#
|
||||
GAME_TETRIS=y
|
||||
GAME_SPACE_INVADERS=y
|
||||
GAME_SNAKE=y
|
||||
|
||||
#
|
||||
# Animations
|
||||
#
|
||||
ANIMATION_SCROLLTEXT=y
|
||||
ANIMATION_SPIRALE=y
|
||||
ANIMATION_JOERN1=y
|
||||
ANIMATION_SNAKE=y
|
||||
ANIMATION_SCHACHBRETT=y
|
||||
ANIMATION_FEUER=y
|
||||
ANIMATION_MATRIX=y
|
||||
ANIMATION_RANDOM_BRIGHT=y
|
||||
ANIMATION_GAMEOFLIFE=y
|
||||
ANIMATION_TESTS=y
|
||||
ANIMATION_OFF=y
|
|
@ -33,9 +33,11 @@ static void init(){
|
|||
}
|
||||
}
|
||||
|
||||
extern uint8_t _eeprom_start__[];
|
||||
|
||||
uint16_t conv_addr(uint8_t * p){
|
||||
uint16_t addr;
|
||||
addr = (unsigned int)p;
|
||||
addr = (unsigned int)p - (unsigned int)_eeprom_start__;
|
||||
if(addr >= EEPROM_SIZE){
|
||||
printf ("warning: eeprom write to %X\n",addr);
|
||||
}
|
||||
|
@ -52,8 +54,8 @@ void eeprom_write_byte (uint8_t *p, uint8_t value){
|
|||
|
||||
void eeprom_write_word (uint16_t *p, uint16_t value){
|
||||
init();
|
||||
eemem[conv_addr(p) ] = value & 0xff;
|
||||
eemem[conv_addr(p)+1] = value >> 8;
|
||||
eemem[conv_addr((uint8_t*)p) ] = value & 0xff;
|
||||
eemem[conv_addr((uint8_t*)p)+1] = value >> 8;
|
||||
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
fwrite(eemem, 1, EEPROM_SIZE, fp);
|
||||
|
@ -67,5 +69,5 @@ uint8_t eeprom_read_byte (uint8_t *p){
|
|||
|
||||
uint16_t eeprom_read_word (uint16_t *p){
|
||||
init();
|
||||
return eemem[conv_addr(p)] | (eemem[conv_addr(p)+1]<<8);
|
||||
return eemem[conv_addr((uint8_t*)p)] | (eemem[conv_addr((uint8_t*)p)+1]<<8);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ OUTPUT_FORMAT(pei-i386)
|
|||
SEARCH_DIR("/usr/i686-pc-cygwin/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/usr/lib"); SEARCH_DIR("/usr/lib/w32api");
|
||||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
/*.eeprom (NOLOAD) : { *.(eeprom) }*/
|
||||
/* Make the virtual address and file offset synced if the alignment is
|
||||
lower than the target page size. */
|
||||
. = SIZEOF_HEADERS;
|
||||
|
@ -38,6 +36,8 @@ SECTIONS
|
|||
*(.data2)
|
||||
*(SORT(.data$*))
|
||||
*(.jcr)
|
||||
__eeprom_start__ = . ;
|
||||
*(.eeprom)
|
||||
__game_descriptors_start__ = . ;
|
||||
*(.game_descriptors)
|
||||
__game_descriptors_end__ = . ;
|
||||
|
|
Loading…
Reference in New Issue