1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 07:29:33 +00:00
cc65/test/val/bug1071.c

88 lines
1.8 KiB
C
Raw Permalink Normal View History

2020-07-09 13:57:51 +00:00
/* test related to issue #1071 */
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
struct ImageStruct
{
2020-12-25 06:16:26 +00:00
uint8_t _imageData;
#if !defined(NO_COLOR)
uint8_t _color;
#endif
2020-07-09 13:57:51 +00:00
};
typedef struct ImageStruct Image;
struct CharacterStruct
{
2020-12-25 06:16:26 +00:00
// character coordinates
uint8_t _x;
uint8_t _y;
2020-07-09 13:57:51 +00:00
2020-12-25 06:16:26 +00:00
// _status decides whether the character is active
uint8_t _status;
2020-07-09 13:57:51 +00:00
2020-12-25 06:16:26 +00:00
Image* _imagePtr;
2020-07-09 13:57:51 +00:00
};
typedef struct CharacterStruct Character;
uint16_t ghostLevel;
uint8_t level;
uint16_t loop;
#define GHOSTS_NUMBER 10
#define BOMBS_NUMBER 3
#define MAX_GHOST_LEVEL_SCALE 3
#define MAX_GHOST_LEVEL (1400/MAX_GHOST_LEVEL_SCALE)
#define MAX_GHOST_LOOP_SCALE 3
#define MAX_GHOST_LOOP (1800/MAX_GHOST_LOOP_SCALE)
#define INITIAL_GHOST_SLOWDOWN 16000
#define ACTION_GHOST_MIN_SLOWDOWN_SCALE 1
#define GHOST_MIN_SLOWDOWN_SCALE ACTION_GHOST_MIN_SLOWDOWN_SCALE
#define GHOST_MIN_SLOWDOWN (3000/GHOST_MIN_SLOWDOWN_SCALE)
Character ghosts[GHOSTS_NUMBER];
Character bombs[BOMBS_NUMBER];
uint16_t test1(void)
{
2020-12-25 06:16:26 +00:00
if((loop<MAX_GHOST_LOOP) && (ghostLevel<MAX_GHOST_LEVEL))
{
return INITIAL_GHOST_SLOWDOWN-(uint16_t)level*256-ghostLevel*8;
}
return GHOST_MIN_SLOWDOWN;
2020-07-09 13:57:51 +00:00
}
uint16_t test2(void)
{
2020-12-25 06:16:26 +00:00
if((loop<MAX_GHOST_LOOP) && (ghostLevel<MAX_GHOST_LEVEL))
{
return INITIAL_GHOST_SLOWDOWN-(uint16_t)level*256-ghostLevel*16;
}
return GHOST_MIN_SLOWDOWN;
2020-07-09 13:57:51 +00:00
}
uint16_t res = 0;
int main(void)
{
loop = 7;
ghostLevel = 13;
level = 3;
res = test1();
printf("test1 res: %d\n", res);
if (res != 15128) return -1;
res = test2();
printf("test2 res: %d\n", res);
if (res != 15024) return -1;
return 0;
}