using unsigned literals produces better code regarding modulo operations

This commit is contained in:
Christian Kroll 2011-10-29 23:44:51 +00:00
parent d4cbcb9b7b
commit c3bd8e0913
2 changed files with 34 additions and 29 deletions

View File

@ -5,41 +5,43 @@ comment "Animations"
bool "Joern1" ANIMATION_JOERN1
dep_bool_menu "Snake" ANIMATION_SNAKE $RANDOM_SUPPORT
int "Snake round delay" SNAKE_CYCLE_DELAY 100
int "Snake termination delay" SNAKE_TERMINATION_DELAY 60
int "Snake max length" SNAKE_MAX_LENGTH 64
int "Snake max apples" SNAKE_MAX_APPLES 10
int "Snake round delay" SNAKE_CYCLE_DELAY 100
int "Snake termination delay" SNAKE_TERMINATION_DELAY 60
uint "Snake max length" SNAKE_MAX_LENGTH 64
int "Snake max apples" SNAKE_MAX_APPLES 10
endmenu
bool "Schachbrett" ANIMATION_SCHACHBRETT
dep_bool_menu "Feuer" ANIMATION_FEUER $RANDOM_SUPPORT
int "FEUER_S" FEUER_S 30
int "FEUER_N" FEUER_N 5
int "FEUER_DIV" FEUER_DIV 44
int "FEUER_DELAY" FEUER_DELAY 50
dep_bool_menu "Feuer" ANIMATION_FEUER $RANDOM_SUPPORT
int "FEUER_S" FEUER_S 30
int "FEUER_N" FEUER_N 5
int "FEUER_DIV" FEUER_DIV 44
int "FEUER_DELAY" FEUER_DELAY 50
int "Fire number of cycles" FIRE_CYCLES 800
endmenu
dep_bool_menu "Matrix" ANIMATION_MATRIX $RANDOM_SUPPORT
int "Number of streamers" MATRIX_STREAMER_NUM 30
int "Run for this number of rounds" MATRIX_CYCLES 500
int "Number of streamers" MATRIX_STREAMER_NUM 30
int "Run for this number of rounds" MATRIX_CYCLES 500
endmenu
dep_bool "Random Bright" ANIMATION_RANDOM_BRIGHT $RANDOM_SUPPORT
dep_bool "Stonefly" ANIMATION_STONEFLY $GAME_TETRIS_CORE
dep_bool "Flying Dots" ANIMATION_FLYINGDOTS $RANDOM_SUPPORT
dep_bool_menu "Game of Life" ANIMATION_GAMEOFLIFE $RANDOM_SUPPORT
int "Game of Life round delay (ms)" GOL_DELAY 100
int "Game of Life max rounds" GOL_CYCLES 360
int "Game of Life round delay (ms)" GOL_DELAY 100
int "Game of Life max rounds" GOL_CYCLES 360
endmenu
dep_bool "Breakout Demo" ANIMATION_BREAKOUT $GAME_BREAKOUT
bool "Martin Herweg" ANIMATION_MHERWEG $RANDOM_SUPPORT
dep_bool "Martin Herweg" ANIMATION_MHERWEG $RANDOM_SUPPORT
dep_bool "Langton Ant" ANIMATION_LTN_ANT $RANDOM_SUPPORT
dep_bool_menu "Time Display" ANIMATION_TIME $SCROLLTEXT_SUPPORT $LAP_TIME_EXTENSION
int "Time master address (int)" TIME_MASTER_ADDR 00
int "Request timeout (ms)" TIME_UPDATE_TIMEOUT 50
dep_bool_menu "Time Display" ANIMATION_TIME $SCROLLTEXT_SUPPORT $LAP_TIME_EXTENSION
int "Time master address (int)" TIME_MASTER_ADDR 00
int "Request timeout (ms)" TIME_UPDATE_TIMEOUT 50
endmenu
dep_bool_menu "Bitmap Scroller" ANIMATION_BMSCROLLER y $RANDOM_SUPPORT

View File

@ -27,10 +27,13 @@ game_descriptor_t snake_game_descriptor __attribute__((section(".game_descriptor
#define SNAKE_NEWCONTROL
// limits
#ifndef SNAKE_MAX_LENGTH
#define SNAKE_MAX_LENGTH 64u
#ifndef USNAKE_MAX_LENGTH
#define USNAKE_MAX_LENGTH 64u
#endif
#ifndef SNAKE_MAX_APPLES
#define SNAKE_MAX_APPLES 10
#endif
#define SNAKE_MAX_APPLES 10
// delays (in milliseconds)
#ifndef SNAKE_CYCLE_DELAY
@ -69,10 +72,10 @@ enum snake_dir
*/
typedef struct snake_protagonist
{
pixel aSegments[SNAKE_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. */
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;
@ -166,8 +169,8 @@ static snake_dir_t snake_queryJoystick(void)
*/
static void snake_initGameProtagonist(snake_protagonist_t *pprotSnake)
{
pprotSnake->aSegments[0] = (pixel){4, NUM_ROWS - 2};
pprotSnake->aSegments[1] = (pixel){4, NUM_ROWS - 3};
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;
@ -299,7 +302,7 @@ static void snake_eliminateProtagonist(snake_protagonist_t *pprotSnake)
while (pprotSnake->nTailIndex != pprotSnake->nHeadIndex)
{
clearpixel(pprotSnake->aSegments[pprotSnake->nTailIndex++]);
pprotSnake->nTailIndex %= SNAKE_MAX_LENGTH;
pprotSnake->nTailIndex %= USNAKE_MAX_LENGTH;
wait(SNAKE_TERMINATION_DELAY);
}
}
@ -394,7 +397,7 @@ void snake_engine(uint8_t bDemoMode)
// actually move head
pixel pxOldHead = protSnake.aSegments[protSnake.nHeadIndex];
protSnake.nHeadIndex = (protSnake.nHeadIndex + 1) % SNAKE_MAX_LENGTH;
protSnake.nHeadIndex = (protSnake.nHeadIndex + 1) % USNAKE_MAX_LENGTH;
protSnake.aSegments[protSnake.nHeadIndex] =
snake_applyDirection(pxOldHead, protSnake.dir);
@ -411,7 +414,7 @@ void snake_engine(uint8_t bDemoMode)
// remove last segment
clearpixel(protSnake.aSegments[protSnake.nTailIndex])
protSnake.nTailIndex = (protSnake.nTailIndex +1) % SNAKE_MAX_LENGTH;
protSnake.nTailIndex = (protSnake.nTailIndex +1) % USNAKE_MAX_LENGTH;
// new apples
snake_spawnApples(&apples);