#include #define STARTBOARD_X 11 /* X start position of the board on the screen */ #define STARTBOARD_Y 2 /* Y start position of the board on the screen */ #define BOARD_CHAR_LEFT 6 #define BOARD_CHAR_RIGHT 6 #define CRUNCH_CHAR_1 13 #define CRUNCH_COLOR_1 FG_BG(COLOR_BLACK, COLOR_GREY) #define CRUNCH_CHAR_2 32 #define CRUNCH_COLOR_2 FG_BG(COLOR_BLACK, COLOR_BLACK) #define POS_SCORE_X 23 #define POS_SCORE_Y 1 #define POS_LEVEL_X 23 #define POS_LEVEL_Y 7 #define POS_LINES_X 23 #define POS_LINES_Y 13 #define POS_NEXT_X 1 #define POS_NEXT_Y 1 #define NEXT_X (POS_NEXT_X+2) #define NEXT_Y (POS_NEXT_Y+3) void updateScore(); void drawPlayground(); void gameOver(); void gr_drawpiece(sprite *p); void gr_erasepiece(sprite *p); void gr_update_board(); void gr_crunch_line(byte line, byte crunch_char, byte crunch_color); // grahpic board // #include // for sprintf // #include #include "keyboard_input.h" #include "fonts.h" #include "pieces.h" #include "ckboard.h" extern unsigned long score; void right_pad_number(unsigned long number) { ultoa(number, tmp, DECIMAL); int l = (int) strlen(tmp); int offset = 6-l; for(int i=l;i>=0;i--) tmp[i+offset] = tmp[i]; // move to the right for(int i=0;ipiece, p->angle); int px = p->x; int py = p->y; // are we erasing the "next" piece ? if(py==PIECE_IS_NEXT) { px = NEXT_X; py = NEXT_Y; } else { px += STARTBOARD_X; py += STARTBOARD_Y; } for(byte t=0; t<4; t++) { #ifdef KICKC_NIGHTLY int x = px + (int) data->offset_x; int y = py + (int) data->offset_y; #else int x = px; byte x1 = data->offset_x; x+= (int) x1; int y = py; byte y1 = data->offset_y; y+= (int) y1; #endif data++; draw_tile((byte)x,(byte)y,EMPTY_GR_CHAR,EMPTY_GR_COLOR); } } // erase piece from the screen void gr_erasepiece_unmarked(sprite *p) { tile_offset *data = get_piece_offsets(p->piece, p->angle); int px = p->x; int py = p->y; int zx = px; int zy = py; px += STARTBOARD_X; py += STARTBOARD_Y; for(byte t=0; t<4; t++) { #ifdef KICKC_NIGHTLY int x = px + (int) data->offset_x; int y = py + (int) data->offset_y; int cx = p->x + (int) data->offset_x; int cy = p->y + (int) data->offset_y; #else int x = px; byte x1 = data->offset_x; x+= (int) x1; int y = py; byte y1 = data->offset_y; y+= (int) y1; int cx = p->x; cx += (int) x1; int cy = p->y; cy += (int) y1; #endif data++; if(READ_BOARD(cy,cx) != MARKED) { draw_tile((byte)x,(byte)y,EMPTY_GR_CHAR,EMPTY_GR_COLOR); } } } // draw a piece on the screen void gr_drawpiece(sprite *p) { tile_offset *data = get_piece_offsets(p->piece, p->angle); int px = p->x; int py = p->y; // are we drawing the "next" piece ? if(py==PIECE_IS_NEXT) { px = NEXT_X; py = NEXT_Y; } else { px += STARTBOARD_X; py += STARTBOARD_Y; } byte piece = p->piece; for(byte t=0; t<4; t++) { #ifdef KICKC_NIGHTLY int x = px + (int) data->offset_x; int y = py + (int) data->offset_y; #else int x = px; byte x1 = data->offset_x; x+= (int) x1; int y = py; byte y1 = data->offset_y; y+= (int) y1; #endif data++; byte ch = piece_chars[piece]; byte col = piece_colors[piece]; draw_tile((byte)x,(byte)y,ch,col); } } // fills the specified line with an empty character void gr_crunch_line(byte line, byte crunch_char, byte crunch_color) { for(byte i=0; i