Browse Source

Game and menu support added. Dependencies fixed. Compiles fine for AVR and Windows. Linux simulator is still missing a linker script.

feature/2015
tixiv 16 years ago
parent
commit
44e84677e7
  1. 3
      Makefile
  2. 1
      animations/snake.c
  3. 4
      avr5.x
  4. 27
      config.in
  5. 2
      defaults.mk
  6. 2
      display_loop.c
  7. 12
      games/Makefile
  8. 9
      games/config.in
  9. 12
      games/games.mk
  10. 8
      games/snake/Makefile
  11. 14
      games/snake/snake_game.c
  12. 8
      games/space_invaders/Makefile
  13. 0
      games/space_invaders/invader_draw.c
  14. 0
      games/space_invaders/invader_init.c
  15. 4
      games/space_invaders/invader_proc.c
  16. 22
      games/space_invaders/invaders2.c
  17. 15
      games/space_invaders/invaders2.h
  18. 27
      games/tetris/Makefile
  19. 19
      games/tetris/input.c
  20. 21
      games/tetris/logic.c
  21. 16
      games/tetris/view.c
  22. 13
      joystick.c
  23. 33
      joystick.h
  24. 9
      joystick/Makefile
  25. 101
      joystick/config.in
  26. 16
      joystick/joystick.c
  27. 29
      joystick/joystick.h
  28. 5
      main.c
  29. 4
      makros.h
  30. 17
      menu/menu.c
  31. 77
      profiles/borg-16
  32. 10
      simulator/eeprom.c
  33. 4
      simulator/i386pe.x
  34. 2
      util.c

3
Makefile

@ -40,7 +40,6 @@ include defaults.mk
@ echo "checking in which subdirs to build" @ echo "checking in which subdirs to build"
@ $(RM) -f $@ @ $(RM) -f $@
@ echo "SUBDIRS += animations" >> $@ @ echo "SUBDIRS += animations" >> $@
# @ echo "SUBDIRS += animations games menu" >> $@
@ (for subdir in `grep -e "^#define .*_SUPPORT" autoconf.h \ @ (for subdir in `grep -e "^#define .*_SUPPORT" autoconf.h \
| sed -e "s/^#define //" -e "s/_SUPPORT.*//" \ | sed -e "s/^#define //" -e "s/_SUPPORT.*//" \
| tr "[A-Z]\\n" "[a-z] " `; do \ | tr "[A-Z]\\n" "[a-z] " `; do \
@ -54,12 +53,14 @@ ifneq ($(MAKECMDGOALS),menuconfig)
include $(TOPDIR)/.subdirs include $(TOPDIR)/.subdirs
include $(TOPDIR)/.config include $(TOPDIR)/.config
include $(TOPDIR)/games/games.mk
endif # MAKECMDGOALS!=menuconfig endif # MAKECMDGOALS!=menuconfig
endif # MAKECMDGOALS!=mrproper endif # MAKECMDGOALS!=mrproper
endif # MAKECMDGOALS!=clean endif # MAKECMDGOALS!=clean
endif # no_deps!=t endif # no_deps!=t
############################################################################## ##############################################################################
SUBDIRS_AVR = borg_hw SUBDIRS_AVR = borg_hw

1
animations/snake.c

@ -4,7 +4,6 @@
#include "../util.h" #include "../util.h"
#include "../random/prng.h" #include "../random/prng.h"
#include "snake.h" #include "snake.h"
#include "../joystick.h"
#define RANDOM8() (random8()) #define RANDOM8() (random8())

4
avr5.x

@ -154,9 +154,9 @@ SECTIONS
*(.rodata) /* We need to include .rodata here if gcc is used */ *(.rodata) /* We need to include .rodata here if gcc is used */
*(.rodata*) /* with -fdata-sections. */ *(.rodata*) /* with -fdata-sections. */
*(.gnu.linkonce.d*) *(.gnu.linkonce.d*)
__game_descriptors_start__ = . ; PROVIDE (_game_descriptors_start__ = .) ;
*(.game_descriptors) *(.game_descriptors)
__game_descriptors_end__ = . ; PROVIDE (_game_descriptors_end__ = .) ;
. = ALIGN(2); . = ALIGN(2);
_edata = . ; _edata = . ;
PROVIDE (__data_end = .) ; PROVIDE (__data_end = .) ;

27
config.in

@ -20,20 +20,37 @@ comment "General Setup"
endmenu endmenu
############################################################################### ###############################################################################
###################### Borg Hardware Menu ##################################### ###################### Borg Hardware Menu #####################################
source borg_hw/config.in source borg_hw/config.in
############################################################################### ###############################################################################
########################### Features Menu #####################################
mainmenu_option next_comment mainmenu_option next_comment
comment "Features" comment "Features"
bool "prng random number generator" RANDOM_SUPPORT y bool "prng random number generator" RANDOM_SUPPORT y
endmenu endmenu
###############################################################################
########################## Scrolltext Menu #################################### ########################## Scrolltext Menu ####################################
source scrolltext/config.in 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 ##################################### ######################### Animations Menu #####################################
mainmenu_option next_comment mainmenu_option next_comment
@ -43,12 +60,12 @@ comment "Animations"
dep_bool "Scrolltext" ANIMATION_SCROLLTEXT $SCROLLTEXT_SUPPORT dep_bool "Scrolltext" ANIMATION_SCROLLTEXT $SCROLLTEXT_SUPPORT
bool "Spirale" ANIMATION_SPIRALE bool "Spirale" ANIMATION_SPIRALE
bool "Joern1" ANIMATION_JOERN1 bool "Joern1" ANIMATION_JOERN1
bool "Snake" ANIMATION_SNAKE dep_bool "Snake" ANIMATION_SNAKE $RANDOM_SUPPORT
bool "Schachbrett" ANIMATION_SCHACHBRETT bool "Schachbrett" ANIMATION_SCHACHBRETT
bool "Feuer" ANIMATION_FEUER dep_bool "Feuer" ANIMATION_FEUER $RANDOM_SUPPORT
bool "Matrix" ANIMATION_MATRIX dep_bool "Matrix" ANIMATION_MATRIX $RANDOM_SUPPORT
bool "Random bright" ANIMATION_RANDOM_BRIGHT dep_bool "Random bright" ANIMATION_RANDOM_BRIGHT $RANDOM_SUPPORT
bool "Game of Life" ANIMATION_GAMEOFLIFE dep_bool "Game of Life" ANIMATION_GAMEOFLIFE $RANDOM_SUPPORT
comment "Special Animations" comment "Special Animations"
bool "Test Animations" ANIMATION_TESTS bool "Test Animations" ANIMATION_TESTS

2
defaults.mk

@ -22,7 +22,7 @@ CFLAGS ?= -Wall -W -Wno-unused-parameter -Wno-sign-compare
CFLAGS += -g -Os -std=gnu99 -fgnu89-inline CFLAGS += -g -Os -std=gnu99 -fgnu89-inline
# flags for the linker # flags for the linker
LDFLAGS += -mmcu=$(MCU) -T avr5.x LDFLAGS += -T ./avr5.x -mmcu=$(MCU)
############################################################################# #############################################################################

2
display_loop.c

@ -14,7 +14,7 @@
#include "mcuf/mcuf.h" #include "mcuf/mcuf.h"
#include "menu/menu.h" #include "menu/menu.h"
#include "pixel.h" #include "pixel.h"
#include "joystick.h" #include "joystick/joystick.h"
volatile unsigned char oldMode, oldOldmode, mode; volatile unsigned char oldMode, oldOldmode, mode;

12
games/Makefile

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

9
games/config.in

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

12
games/games.mk

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

8
games/snake/Makefile

@ -0,0 +1,8 @@
TARGET =
TOPDIR = ../..
include $(TOPDIR)/defaults.mk
SRC = snake_game.c
include $(TOPDIR)/rules.mk

14
games/snake_game.c → games/snake/snake_game.c

@ -1,11 +1,11 @@
#include "../config.h" #include "../../config.h"
#include "../compat/pgmspace.h" #include "../../compat/pgmspace.h"
#include "../menu/menu.h" #include "../../menu/menu.h"
#include "../pixel.h" #include "../../pixel.h"
#include "../random/prng.h" #include "../../random/prng.h"
#include "../util.h" #include "../../util.h"
#include "../joystick.h" #include "../../joystick/joystick.h"
// MSB is leftmost pixel // MSB is leftmost pixel
static uint8_t icon[8] PROGMEM = static uint8_t icon[8] PROGMEM =

8
games/space_invaders/Makefile

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

0
games/invader_draw.c → games/space_invaders/invader_draw.c

0
games/invader_init.c → games/space_invaders/invader_init.c

4
games/invader_proc.c → games/space_invaders/invader_proc.c

@ -1,5 +1,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "prng.h" #include "../../config.h"
#include "../../joystick/joystick.h"
#include "../../random/prng.h"
#include "invaders2.h" #include "invaders2.h"
void procCannon(Cannon * cn, uPixel * shot) void procCannon(Cannon * cn, uPixel * shot)

22
games/invaders2.c → games/space_invaders/invaders2.c

@ -1,12 +1,24 @@
#include <stdio.h> #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 "invaders2.h"
//#include <stdio.h> //#include <stdio.h>
#ifndef __AVR__ // MSB is leftmost pixel
#define wait(_X) myWait(_X) static uint8_t icon[8] PROGMEM =
#endif {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() void borg_invaders()
{ {
@ -118,9 +130,11 @@ void borg_invaders()
clearScreen (); clearScreen ();
//wait(5000); //wait(5000);
#ifdef SCROLLTEXT_SUPPORT
char text[64]; char text[64];
snprintf(text, 64, "</#points: %u", pl.points); snprintf(text, 64, "</#points: %u", pl.points);
scrolltext(text); scrolltext(text);
#endif
//printf("scores: %d\n", pl.points); //printf("scores: %d\n", pl.points);

15
games/invaders2.h → games/space_invaders/invaders2.h

@ -9,13 +9,11 @@
#ifndef INVADERS2_H #ifndef INVADERS2_H
#define INVADERS2_H #define INVADERS2_H
/* TEST PARTS NEW API */
#define USE_ORIGINAL_PIXEL_API #include "../../config.h"
#include "../../pixel.h"
/*CONNECTION TO SIMULATOR*/
//extern char fkey;
/* TEST PARTS NEW API */
typedef struct typedef struct
{ {
@ -29,11 +27,10 @@ typedef struct
unsigned char y; unsigned char y;
} uPixel; } uPixel;
//for compatibility to pisel.h api! #define USE_ORIGINAL_PIXEL_API
//for compatibility to pixel.h api!
#ifdef USE_ORIGINAL_PIXEL_API #ifdef USE_ORIGINAL_PIXEL_API
#include "pixel.h"
#include "scrolltext.h"
#include "joystick.h"
//typedef uPixel pixel; //typedef uPixel pixel;
#define uPixel pixel #define uPixel pixel

27
games/tetris/Makefile

@ -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 SRC = piece.c playfield.c view.c logic.c input.c
$(LD) -r piece.o playfield.o view.o logic.o input.o -o tetris.o
piece.o: piece.c piece.h include $(TOPDIR)/rules.mk
$(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

19
games/tetris/input.c

@ -2,23 +2,14 @@
#include <string.h> #include <string.h>
#include <inttypes.h> #include <inttypes.h>
#include <assert.h> #include <assert.h>
#include "../joystick.h" #include "../../config.h"
#include "../util.h" #include "../../joystick/joystick.h"
#include "../../util.h"
#include "input.h" #include "input.h"
/* - the API simulator and the real API have different named wait functions #include "../../compat/pgmspace.h"
* - the macro PM helps in reading values from PROGMEM on the AVR arch
*/
#ifdef __AVR__
#include <avr/pgmspace.h>
#define WAIT(ms) wait(ms) #define WAIT(ms) wait(ms)
#define PM(value) pgm_read_word(&value) #define PM(value) pgm_read_word(&value)
#else
#define PROGMEM
#define WAIT(ms) myWait(ms)
#define PM(value) (value)
#endif
/*********** /***********
* defines * * 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 // amount of loop cycles a command is ignored after its button has been
// released (every command has its own counter) // 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_CW,
TETRIS_INPUT_CHATTER_TICKS_ROT_CCW, TETRIS_INPUT_CHATTER_TICKS_ROT_CCW,

21
games/tetris/logic.c

@ -8,17 +8,16 @@
#include <assert.h> #include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#ifdef __AVR__ #include "../../compat/eeprom.h"
#include <avr/eeprom.h> #include "../../compat/pgmspace.h"
#include <avr/interrupt.h> #include "../../menu/menu.h"
#endif
#include "logic.h" #include "logic.h"
#include "piece.h" #include "piece.h"
#include "playfield.h" #include "playfield.h"
#include "view.h" #include "view.h"
#include "input.h" #include "input.h"
#include "../prng.h" #include "../../random/prng.h"
#ifdef EEMEM #ifdef EEMEM
@ -29,6 +28,18 @@
uint16_t tetris_logic_nHighscore EEMEM; uint16_t tetris_logic_nHighscore EEMEM;
#endif #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 * * non-interface functions *
***************************/ ***************************/

16
games/tetris/view.c

@ -3,22 +3,16 @@
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#include "../config.h" #include "../../config.h"
#include "../pixel.h" #include "../../pixel.h"
#include "../util.h" #include "../../util.h"
#include "../scrolltext.h" #include "../../scrolltext/scrolltext.h"
#include "logic.h" #include "logic.h"
#include "piece.h" #include "piece.h"
#include "playfield.h" #include "playfield.h"
#include "view.h" #include "view.h"
/* the API simulator and the real API have different named wait functions */
#ifdef __AVR__
#define WAIT(ms) wait(ms) #define WAIT(ms) wait(ms)
#else
#define WAIT(ms) myWait(ms)
#endif
/*********** /***********
* defines * * defines *
@ -416,6 +410,8 @@ void tetris_view_showResults(tetris_view_t *pV)
"</#Lines %u New Highscore %u", nLines, nScore); "</#Lines %u New Highscore %u", nLines, nScore);
} }
#ifdef SCROLLTEXT_SUPPORT
scrolltext(pszResults); scrolltext(pszResults);
#endif
} }

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

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

9
joystick/Makefile

@ -0,0 +1,9 @@
TARGET =
TOPDIR = ..
include $(TOPDIR)/defaults.mk
SRC = joystick.c
SRC_SIM =
include $(TOPDIR)/rules.mk

101
joystick/config.in

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

16
joystick/joystick.c

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

29
joystick/joystick.h

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

@ -9,6 +9,11 @@
#include "random/prng.h" #include "random/prng.h"
#include "random/persistentCounter.h" #include "random/persistentCounter.h"
#include "display_loop.h" #include "display_loop.h"
#include "pixel.h"
#ifdef JOYSTICK_SUPPORT
#include "joystick/joystick.h"
#endif
int main (void){ int main (void){
clear_screen(0); clear_screen(0);

4
makros.h

@ -1,2 +1,6 @@
#define DDR(port) (*(volatile uint8_t*)((&port)-1)) #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

@ -14,14 +14,14 @@
#include "../config.h" #include "../config.h"
#include "../util.h" #include "../util.h"
#include "../pixel.h" #include "../pixel.h"
#include "../joystick.h" #include "../joystick/joystick.h"
extern game_descriptor_t _game_descriptors_start__[]; extern game_descriptor_t _game_descriptors_start__[];
extern game_descriptor_t _game_descriptors_end__[]; extern game_descriptor_t _game_descriptors_end__[];
// defines // 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_WIDTH_ICON 8
#define MENU_HEIGHT_ICON 8 #define MENU_HEIGHT_ICON 8
@ -48,6 +48,8 @@ void menu()
wait(MENU_POLL_INTERVAL); wait(MENU_POLL_INTERVAL);
} }
if(MENU_ITEM_MAX == 0) goto end;
// set initial menu item // set initial menu item
static uint8_t miSelection = 0; static uint8_t miSelection = 0;
// scroll in currently selected menu item // scroll in currently selected menu item
@ -102,6 +104,7 @@ void menu()
} }
} }
end:
waitForFire = 1; waitForFire = 1;
return; return;
} }
@ -109,16 +112,6 @@ void menu()
uint8_t menu_getIconPixel(uint8_t item, int8_t x, int8_t y) 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? // is x within the icon or do we have reached the delimiter?
if (x < MENU_WIDTH_ICON) if (x < MENU_WIDTH_ICON)
{ {

77
profiles/borg-16

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

10
simulator/eeprom.c

@ -33,9 +33,11 @@ static void init(){
} }
} }
extern uint8_t _eeprom_start__[];
uint16_t conv_addr(uint8_t * p){ uint16_t conv_addr(uint8_t * p){
uint16_t addr; uint16_t addr;
addr = (unsigned int)p; addr = (unsigned int)p - (unsigned int)_eeprom_start__;
if(addr >= EEPROM_SIZE){ if(addr >= EEPROM_SIZE){
printf ("warning: eeprom write to %X\n",addr); 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){ void eeprom_write_word (uint16_t *p, uint16_t value){
init(); init();
eemem[conv_addr(p) ] = value & 0xff; eemem[conv_addr((uint8_t*)p) ] = value & 0xff;
eemem[conv_addr(p)+1] = value >> 8; eemem[conv_addr((uint8_t*)p)+1] = value >> 8;
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);
fwrite(eemem, 1, EEPROM_SIZE, fp); 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){ uint16_t eeprom_read_word (uint16_t *p){
init(); 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);
} }

4
simulator/i386pe.x

@ -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"); SEARCH_DIR("/usr/i686-pc-cygwin/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/usr/lib"); SEARCH_DIR("/usr/lib/w32api");
SECTIONS SECTIONS
{ {
. = 0;
/*.eeprom (NOLOAD) : { *.(eeprom) }*/
/* Make the virtual address and file offset synced if the alignment is /* Make the virtual address and file offset synced if the alignment is
lower than the target page size. */ lower than the target page size. */
. = SIZEOF_HEADERS; . = SIZEOF_HEADERS;
@ -38,6 +36,8 @@ SECTIONS
*(.data2) *(.data2)
*(SORT(.data$*)) *(SORT(.data$*))
*(.jcr) *(.jcr)
__eeprom_start__ = . ;
*(.eeprom)
__game_descriptors_start__ = . ; __game_descriptors_start__ = . ;
*(.game_descriptors) *(.game_descriptors)
__game_descriptors_end__ = . ; __game_descriptors_end__ = . ;

2
util.c

@ -1,7 +1,7 @@
#include <avr/io.h> #include <avr/io.h>
#include <setjmp.h> #include <setjmp.h>
#include "joystick.h" #include "joystick/joystick.h"
//this buffer is declared in main //this buffer is declared in main
extern jmp_buf newmode_jmpbuf; extern jmp_buf newmode_jmpbuf;

Loading…
Cancel
Save