2010-01-15 12:19:54 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
uint8_t brick_damage (uint8_t in_x, uint8_t in_y)
|
|
|
|
{
|
|
|
|
game_field_t newtype;
|
|
|
|
|
2010-01-15 12:31:58 +00:00
|
|
|
if (playfield[in_x][in_y] > bs || playfield[in_x][in_y] == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
playfield[in_x][in_y]--;
|
2010-01-15 12:19:54 +00:00
|
|
|
score_add (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t check_bounce (uint8_t in_x, uint8_t in_y)
|
|
|
|
{
|
|
|
|
/* overflow check */
|
|
|
|
if (in_x >= NUM_ROWS)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (in_y >= NUM_COLS)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* collisions with real objects */
|
|
|
|
switch (playfield[in_x][in_y])
|
|
|
|
{
|
2010-01-15 12:31:58 +00:00
|
|
|
case sp:
|
|
|
|
case bl:
|
2010-01-15 12:19:54 +00:00
|
|
|
return 0;
|
|
|
|
|
2010-01-15 12:31:58 +00:00
|
|
|
case b2:
|
|
|
|
case b3:
|
|
|
|
case b1:
|
2010-01-15 12:19:54 +00:00
|
|
|
brick_damage (in_x, in_y);
|
|
|
|
/* intentional fallthrough */
|
|
|
|
|
2010-01-15 12:31:58 +00:00
|
|
|
case bs:
|
2010-01-15 12:19:54 +00:00
|
|
|
return 1;
|
2010-01-15 12:31:58 +00:00
|
|
|
|
|
|
|
/* bouncing on the rebound needs special care */
|
|
|
|
case rb:
|
|
|
|
return 2;
|
2010-01-15 12:19:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is the actual draw function for a single field
|
|
|
|
*/
|
2010-01-15 14:42:46 +00:00
|
|
|
static inline void draw_single_field (uint8_t in_x, uint8_t in_y, game_field_t in_f)
|
2010-01-15 12:19:54 +00:00
|
|
|
{
|
|
|
|
switch (in_f)
|
|
|
|
{
|
|
|
|
case b1:
|
2010-01-15 14:42:46 +00:00
|
|
|
setPixel (in_x, in_y, 1);
|
2010-01-15 12:19:54 +00:00
|
|
|
return;
|
|
|
|
case rb:
|
|
|
|
case b2:
|
2010-01-15 14:42:46 +00:00
|
|
|
setPixel (in_x, in_y, 2);
|
2010-01-15 12:19:54 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case b3:
|
|
|
|
case bl:
|
|
|
|
case bs:
|
2010-01-15 14:42:46 +00:00
|
|
|
setPixel (in_x, in_y, 3);
|
2010-01-15 12:19:54 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
default: /* this includes freespace */
|
2010-01-15 14:42:46 +00:00
|
|
|
setPixel (in_x, in_y, 0);
|
2010-01-15 12:19:54 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void playfield_draw ()
|
|
|
|
{
|
|
|
|
uint8_t x,y;
|
|
|
|
|
|
|
|
for (x=0;x<NUM_ROWS;x++)
|
|
|
|
{
|
|
|
|
for (y=0;y<NUM_COLS;y++)
|
|
|
|
{
|
2010-01-15 14:42:46 +00:00
|
|
|
draw_single_field (x,y, playfield[x][y]);
|
2010-01-15 12:19:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|