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:
tixiv 2009-01-02 02:18:20 +00:00
commit 44e84677e7
34 changed files with 397 additions and 171 deletions

View file

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

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

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

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

View file

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

View file

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

View file

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

View file

@ -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);
char text[64];
snprintf(text, 64, "</#points: %u", pl.points);
scrolltext(text);
#ifdef SCROLLTEXT_SUPPORT
char text[64];
snprintf(text, 64, "</#points: %u", pl.points);
scrolltext(text);
#endif
//printf("scores: %d\n", pl.points);

View file

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

View file

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

View file

@ -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>
#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
#include "../../compat/pgmspace.h"
#define WAIT(ms) wait(ms)
#define PM(value) pgm_read_word(&value)
/***********
* 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,

View file

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

View file

@ -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
#define WAIT(ms) wait(ms)
/***********
* 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
}