void initdisplay_rat(uint8_t inverted) { glcdFillRectangle(0, 0, GLCD_XPIXELS, GLCD_YPIXELS, inverted); // draw top 'line' glcdFillRectangle(0, 0, GLCD_XPIXELS, 2, ! inverted); // bottom line glcdFillRectangle(0, GLCD_YPIXELS - 2, GLCD_XPIXELS, 2, ! inverted); // left paddle glcdFillRectangle(LEFTPADDLE_X, INT_MSB(leftpaddle_y), PADDLE_W, PADDLE_H, ! inverted); //!! glcdFillRectangle(LEFTPADDLE_X, *((uint8_t *) (&leftpaddle_y)+1), PADDLE_W, PADDLE_H, ! inverted); // right paddle glcdFillRectangle(RIGHTPADDLE_X, INT_MSB(rightpaddle_y), PADDLE_W, PADDLE_H, ! inverted); //left_score = time_h; //right_score = time_m; setscore_rat(); // time drawbigdigit(DISPLAY_H10_X_RAT, DISPLAY_TIME_Y_RAT, left_score/10, inverted); drawbigdigit(DISPLAY_H1_X_RAT, DISPLAY_TIME_Y_RAT, left_score%10, inverted); drawbigdigit(DISPLAY_M10_X_RAT, DISPLAY_TIME_Y_RAT, right_score/10, inverted); drawbigdigit(DISPLAY_M1_X_RAT, DISPLAY_TIME_Y_RAT, right_score%10, inverted); drawmidline(inverted); }
// // Function: spotBarUpdate // // Update a single bar (used in Spotfire bar chart and cascade) // void spotBarUpdate(u08 x, u08 width, u08 oldVal, u08 newVal, s08 valXOffset, u08 fillType) { u08 oldBarHeight; u08 newBarHeight; char barValue[3]; // See if there's any need to update a bar if (oldVal == newVal && mcClockInit == GLCD_FALSE) return; // Get height of old bar and new bar oldBarHeight = (u08)((SPOT_BAR_HEIGHT_MAX / (float)SPOT_BAR_VAL_STEPS) * oldVal + 0.5); newBarHeight = (u08)((SPOT_BAR_HEIGHT_MAX / (float)SPOT_BAR_VAL_STEPS) * newVal + 0.5); // If there are no changes in barheight there's no need to repaint the bar if (oldBarHeight != newBarHeight || mcClockInit == GLCD_TRUE) { // Paint new bar if (fillType == FILL_BLANK) { // A FILL_BLANK is in fact drawing the outline of the bar first and // then fill it with blank glcdRectangle(x, SPOT_BAR_Y_START - newBarHeight, width, newBarHeight + 1, mcFgColor); if (newBarHeight > 1) glcdFillRectangle2(x + 1, SPOT_BAR_Y_START - newBarHeight + 1, width - 2, newBarHeight - 1, ALIGN_TOP, fillType, mcFgColor); } else { glcdFillRectangle2(x, SPOT_BAR_Y_START - newBarHeight, width, newBarHeight + 1, ALIGN_BOTTOM, fillType, mcFgColor); } } // Add the bar value (depending on bar value font size) animValToStr(newVal, barValue); glcdPutStr2(x + valXOffset, SPOT_BAR_Y_START - newBarHeight + SPOT_BAR_VAL_Y_OFFSET, FONT_5X7N, barValue, mcFgColor); // Clear the first line between the bar and the bar value glcdFillRectangle(x, SPOT_BAR_Y_START - newBarHeight - 1, width, 1, mcBgColor); // Clear the space left and right of the bar value glcdFillRectangle(x, SPOT_BAR_Y_START - newBarHeight + SPOT_BAR_VAL_Y_OFFSET, valXOffset, -SPOT_BAR_VAL_Y_OFFSET - 1, mcBgColor); glcdFillRectangle(x + width - valXOffset + 1, SPOT_BAR_Y_START - newBarHeight + SPOT_BAR_VAL_Y_OFFSET, valXOffset - 1, -SPOT_BAR_VAL_Y_OFFSET - 1, mcBgColor); // Clear what was above it (if any) if (oldBarHeight > newBarHeight) glcdFillRectangle(x, SPOT_BAR_Y_START - oldBarHeight + SPOT_BAR_VAL_Y_OFFSET, width, oldBarHeight - newBarHeight, mcBgColor); }
// // Function: spotAxisInit // // Paint x/y-axis lines and labels in a Spotfire clock // void spotAxisInit(u08 clockId) { u08 i; u08 xs, xh, y; if (clockId == CHRON_BARCHART || clockId == CHRON_CASCADE || clockId == CHRON_LINECHART) { // Draw x/y-axis lines glcdFillRectangle(8, 23, 1, 34, mcFgColor); glcdFillRectangle(9, 56, 83, 1, mcFgColor); // Draw y-axis value 10 markers for (i = 24; i <= 54; i = i + 5) glcdDot(7, i, mcFgColor); } // Draw clock dependent things and setup coordinates for axis labels if (clockId == CHRON_BARCHART) { // Barchart glcdDot(37, 57, mcFgColor); glcdDot(64, 57, mcFgColor); xs = 72; xh = 16; y=58; } else if (clockId == CHRON_CASCADE || clockId == CHRON_LINECHART) { // Cascade or linechart xs = 75; xh = 13; y = 58; } else if (clockId == CHRON_TRAFLIGHT) { // Trafficlight xs = 78; xh = 10; y = 58; } else if (clockId == CHRON_THERMOMETER) { // Thermometer xs = 78; xh = 10; y = 59; } else // clockId == CHRON_SPEEDDIAL || clockId == CHRON_PIECHART { // Speeddial or piechart xs = 78; xh = 10; y = 54; } // Draw the axis labels glcdPutStr2(xs, y, FONT_5X5P, animSec, mcFgColor); glcdPutStr2(44, y, FONT_5X5P, animMin, mcFgColor); glcdPutStr2(xh, y, FONT_5X5P, animHour, mcFgColor); }
//uint8_t get_font(uint16_t addr) void drawbigfont(uint8_t x, uint8_t y, uint8_t n, uint8_t inverted) { uint8_t i, j; for (i = 0; i < 5; i++) { uint8_t d = get_font(((n-0x20)*5)+i); for (j=0; j<7; j++) { if (d & _BV(j)) { glcdFillRectangle(x+i*2, y+j*2, 2, 2, !inverted); } else { glcdFillRectangle(x+i*2, y+j*2, 2, 2, inverted); } } } }
void initanim_abo(void){ uint8_t k, b, line, eof; uint16_t ix, lineix; ix=0; #ifdef DEATHCHRON glcdFillRectangle(0, 0, GLCD_XPIXELS, GLCD_YPIXELS, 1); death_blitsegs_rom(36,0,logo_p, 57, 64, 1); uint8_t i = (time_s + 5) % 60; while(i != time_s); #endif while (1) { glcdClearScreen(); for (eof=0, lineix=0, line=0; line<8; line++) { if (!eof) { b = eeprom_read_byte(&about[ix++]); if (b==255) { eof = 1; if (!line) {displaystyle = eeprom_read_byte(&EE_STYLE); initanim(); return;} continue; } if (!line) {lineix = ix + b;} k = ((128 - (b * 6))/2)-1; if (k<0) {k=0;} glcdSetAddress(k,line); for(;b>0;b--) { glcdWriteChar(eeprom_read_byte(&about[ix++]),0); } } } ix = lineix; delay_ms(500); } }
void drawdisplay_rat(uint8_t inverted) { setscore_rat(); // erase old ball // *** THIS DOESN'T WORK WITH FIXED=256 glcdFillRectangle(INT_MSB(oldball_x), INT_MSB(oldball_y), BALL_RADIUS*2, BALL_RADIUS*2, inverted); // draw new ball glcdFillRectangle(INT_MSB(ball_x), INT_MSB(ball_y), BALL_RADIUS*2, BALL_RADIUS*2, ! inverted); // draw middle lines around where the ball may have intersected it? if (intersectrect(INT_MSB(oldball_x), INT_MSB(oldball_y), BALL_RADIUS*2, BALL_RADIUS*2, SCREEN_W/2-MIDLINE_W, 0, MIDLINE_W, SCREEN_H)) { // redraw it since we had an intersection drawmidline(inverted); } if (oldleftpaddle_y != leftpaddle_y) { // clear left paddle glcdFillRectangle(LEFTPADDLE_X, INT_MSB(oldleftpaddle_y), PADDLE_W, PADDLE_H, inverted); } // draw left paddle glcdFillRectangle(LEFTPADDLE_X, INT_MSB(leftpaddle_y), PADDLE_W, PADDLE_H, !inverted); if (oldrightpaddle_y != rightpaddle_y) { // clear right paddle glcdFillRectangle(RIGHTPADDLE_X, INT_MSB(oldrightpaddle_y), PADDLE_W, PADDLE_H, inverted); } // draw right paddle glcdFillRectangle(RIGHTPADDLE_X, INT_MSB(rightpaddle_y), PADDLE_W, PADDLE_H, !inverted); if (intersectrect(INT_MSB(oldball_x), INT_MSB(oldball_y), BALL_RADIUS*2, BALL_RADIUS*2, RIGHTPADDLE_X, INT_MSB(rightpaddle_y), PADDLE_W, PADDLE_H)) { glcdFillRectangle(RIGHTPADDLE_X, INT_MSB(rightpaddle_y), PADDLE_W, PADDLE_H, !inverted); } if (intersectrect(INT_MSB(oldball_x), INT_MSB(oldball_y), BALL_RADIUS*2, BALL_RADIUS*2, LEFTPADDLE_X, INT_MSB(leftpaddle_y), PADDLE_W, PADDLE_H)) { glcdFillRectangle(LEFTPADDLE_X, INT_MSB(leftpaddle_y), PADDLE_W, PADDLE_H, !inverted); } // draw time uint8_t redraw_digits; TIMSK2 = 0; //Disable Timer 2 interrupt, to prevent a race condition. if(redraw_time_rat) { redraw_digits = 1; redraw_time_rat = 0; } TIMSK2 = _BV(TOIE2); //Race issue gone, renable. draw_score_rat(redraw_digits,inverted); redraw_digits = 0; }
// // Function: spotMenuBarUpdate // // Put a (not so special) header in a Spotfire clock menu bar // static void spotMenuBarUpdate(void) { // Only get a new menu bar when the date has changed or when we're // initializing if (mcClockDateEvent == GLCD_TRUE || mcClockInit == GLCD_TRUE) { uint8_t i = 1; uint8_t posX; menuBarDriver_t *mbDriver = menuBarDriver; // Find the new menu bar while (i < sizeof(menuBarDriver) / sizeof(menuBarDriver_t)) { if (mcClockNewDD == mbDriver->day && mcClockNewDM == mbDriver->month) break; i++; mbDriver++; } // Only update the menu bar if it has changed if (menuBarId != i) { DEBUG(putstring("Menu bar Id -> ")); DEBUG(uart_putw_dec(i)); DEBUG(putstring_nl("")); // Sync new menu bar menuBarId = i; // Get starting position on x axis if (mbDriver->barText == MBAR_TXT_LEFT) { // Text is to be started at left (with a small align indent) posX = 2; } else { // Text is to be centered posX = glcdGetWidthStr(FONT_5X5P, mbDriver->msg1); if (mbDriver->msg2 != 0) posX = posX + glcdGetWidthStr(FONT_5X5P, mbDriver->msg2); posX = (GLCD_XPIXELS - posX + 1) / 2; } // Clear the current bar glcdFillRectangle(0, 0, GLCD_XPIXELS, 7, mcBgColor); // Print the first and optionally second msg string posX = posX + glcdPutStr2(posX, 1, FONT_5X5P, mbDriver->msg1, mcFgColor); if (mbDriver->msg2 != 0) glcdPutStr2(posX, 1, FONT_5X5P, mbDriver->msg2, mcFgColor); } } }
// // Function: spotCommonInit // // Draw static Spotfire form visualization layout template // void spotCommonInit(char *label, u08 mode) { u08 i; char *sliderLabel; // Either clear everything or only the chart area if (mode == DRAW_INIT_PARTIAL) { u08 pxDone; // Partial init: clear only the chart area glcdFillRectangle(0, 16, 100, 48, mcBgColor); // Visualization title bar pxDone = glcdPutStr2(2, 9, FONT_5X5P, label, mcFgColor); if (pxDone + 2 < AD_X_START) glcdFillRectangle(pxDone + 2, 9, AD_X_START - pxDone - 2, 5, mcBgColor); } else { // Full init: start from scratch // Draw main lines for menu bar, vis title bar and filter panel glcdFillRectangle(0, 7, GLCD_XPIXELS, 1, mcFgColor); glcdFillRectangle(0, 15, GLCD_XPIXELS, 1, mcFgColor); glcdFillRectangle(101, 7, 1, GLCD_YPIXELS - 7, mcFgColor); // Init the Menu bar menuBarId = 255; spotMenuBarUpdate(); // Init the visualization Title bar label glcdPutStr2(2, 9, FONT_5X5P, label, mcFgColor); // Filter panel label glcdPutStr2(104, 9, FONT_5X5P, "FILTERS", mcFgColor); // There are three filter sliders; hour + min + sec for (i = 0; i <= 2; i++) { if (i == 0) sliderLabel = animHour; else if (i == 1) sliderLabel = animMin; else sliderLabel = animSec; // Paint filter slider glcdPutStr2(FP_X_START, FP_Y_START + i * FP_Y_OFFSET_SIZE, FONT_5X5P, sliderLabel, mcFgColor); glcdRectangle(FP_X_START + FP_RF_X_OFFSET, FP_Y_START + i * FP_Y_OFFSET_SIZE + FP_RF_Y_OFFSET, FP_RF_WIDTH, FP_RF_HEIGHT, mcFgColor); glcdFillRectangle(FP_X_START + FP_RS_X_OFFSET, FP_Y_START + i * FP_Y_OFFSET_SIZE + FP_RS_Y_OFFSET, FP_RS_WIDTH, FP_RS_HEIGHT, mcFgColor); } } }
// // Function: spotRangeSliderUpdate // // Update a single filter panel range slider // static void spotRangeSliderUpdate(u08 y, u08 maxVal, u08 oldVal, u08 newVal) { u08 sliderXPosOld; u08 sliderXPosNew; // Get xpos of old and new marker sliderXPosOld = (u08)(((FP_RS_WIDTH - 2) / (float) maxVal) * oldVal + 0.5); sliderXPosNew = (u08)(((FP_RS_WIDTH - 2) / (float) maxVal) * newVal + 0.5); // Only update if there's a need to if (sliderXPosOld != sliderXPosNew || mcClockInit == GLCD_TRUE) { // Remove old range slider location marker glcdFillRectangle(FP_X_START + FP_RS_X_OFFSET + sliderXPosOld, y + FP_RS_Y_OFFSET - 1, 2, 1, mcBgColor); glcdFillRectangle(FP_X_START + FP_RS_X_OFFSET + sliderXPosOld, y + FP_RS_Y_OFFSET + 1, 2, 1, mcBgColor); // Add new range slider location markers glcdFillRectangle(FP_X_START + FP_RS_X_OFFSET + sliderXPosNew, y + FP_RS_Y_OFFSET - 1, 2, 3, mcFgColor); } }
void draw_score_rat(uint8_t redraw_digits, uint8_t inverted) { #ifdef OPTION_DOW_DATELONG uint8_t i; static uint8_t prev_mode; if(score_mode==SCORE_MODE_DOW) { if(prev_mode != SCORE_MODE_DOW) { for(i=0; i<4; i++) drawbigdigit(rat_time_loc[i],DISPLAY_TIME_Y_RAT, 10, inverted); glcdFillRectangle(INT_MSB(ball_x), INT_MSB(ball_y), BALL_RADIUS*2, BALL_RADIUS*2, ! inverted); prev_mode = SCORE_MODE_DOW; } for(i=0; i<3; i++) check_ball_digit_collision(redraw_digits, rat_time_loc[i+5], sdotw(dotw(date_m,date_d,date_y),i), inverted); } else if (score_mode==SCORE_MODE_DATELONG) { if(prev_mode != SCORE_MODE_DATELONG) { if(prev_mode == SCORE_MODE_DOW) { for(i=0; i<3; i++) drawbigfont(rat_time_loc[i+5], DISPLAY_TIME_Y_RAT, ' ', inverted); } if(prev_mode == SCORE_MODE_TIME) { for(i=0; i<4; i++) drawbigdigit(rat_time_loc[i], DISPLAY_TIME_Y_RAT, 10, inverted); } glcdFillRectangle(INT_MSB(ball_x), INT_MSB(ball_y), BALL_RADIUS*2, BALL_RADIUS*2, ! inverted); prev_mode = SCORE_MODE_DATELONG; } for(i=0; i<3; i++) { check_ball_digit_collision(redraw_digits, rat_time_loc[i+4], smon(date_m,i), inverted); } check_ball_digit_collision(redraw_digits, DISPLAY_DAY10_X, right_score/10, inverted); check_ball_digit_collision(redraw_digits, DISPLAY_DAY10_X, right_score%10, inverted); } else { if((prev_mode == SCORE_MODE_DOW) || (prev_mode == SCORE_MODE_DATELONG)) { if(prev_mode == SCORE_MODE_DATELONG) { for(i=0; i<3; i++) drawbigfont(rat_time_loc[i+4], DISPLAY_TIME_Y_RAT, ' ', inverted); drawbigdigit(DISPLAY_DAY10_X, DISPLAY_TIME_Y_RAT, 10, inverted); drawbigdigit(DISPLAY_DAY1_X, DISPLAY_TIME_Y_RAT, 10, inverted); } if(prev_mode == SCORE_MODE_DOW) { for(i=0; i<3; i++) drawbigfont(rat_time_loc[i+5], DISPLAY_TIME_Y_RAT, ' ', inverted); } if(prev_mode == SCORE_MODE_TIME) { for(i=0; i<4; i++) drawbigdigit(rat_time_loc[i], DISPLAY_TIME_Y_RAT, 10, inverted); } glcdFillRectangle(INT_MSB(ball_x), INT_MSB(ball_y), BALL_RADIUS*2, BALL_RADIUS*2, ! inverted); prev_mode = SCORE_MODE_TIME; } #endif check_ball_digit_collision(redraw_digits, DISPLAY_H10_X_RAT,left_score/10,inverted); check_ball_digit_collision(redraw_digits, DISPLAY_H1_X_RAT,left_score%10,inverted); check_ball_digit_collision(redraw_digits, DISPLAY_M10_X_RAT,right_score/10,inverted); check_ball_digit_collision(redraw_digits, DISPLAY_M1_X_RAT,right_score%10,inverted); #ifdef OPTION_DOW_DATELONG } #endif }
void step_rat(void) { // The keepout is used to know where to -not- put the paddle // the 'bouncepos' is where we expect the ball's y-coord to be when // it intersects with the paddle area static uint8_t right_keepout_top, right_keepout_bot; static uint8_t left_keepout_top, left_keepout_bot; static uint16_t dest_paddle_pos; static uint16_t right_dest, left_dest; // Save old ball location so we can do some vector stuff oldball_x = ball_x; oldball_y = ball_y; // move ball according to the vector ball_x += ball_dx; ball_y += ball_dy; /************************************* TOP & BOTTOM WALLS */ // bouncing off bottom wall, reverse direction // if (ball_y > (SCREEN_H_FIXED - BALL_RADIUS*2*FIXED_MATH - BOTBAR_H_FIXED)) { if (ball_y > (SCREEN_H - BOTBAR_H - BALL_RADIUS*2)*FIXED_MATH) { //DEBUG(putstring_nl("bottom wall bounce")); ball_y = (SCREEN_H - BOTBAR_H - BALL_RADIUS*2)*FIXED_MATH; ball_dy = -ball_dy; } // bouncing off top wall, reverse direction if (ball_y < TOPBAR_H_FIXED) { //DEBUG(putstring_nl("top wall bounce")); ball_y = TOPBAR_H_FIXED; ball_dy = -ball_dy; } /************************************* LEFT & RIGHT WALLS */ // the ball hits either wall, the ball resets location & angle if ( ((INT_MSB(ball_x)) > (SCREEN_W - BALL_RADIUS*2)) || ((int8_t)(INT_MSB(ball_x)) <= 0) || ((ball_dx ==0) && (ball_dy==0)) ) { if(DEBUGGING) { if ((int8_t)(INT_MSB(ball_x)) <= 0) { putstring("Left wall collide"); if (! minute_changed) { putstring_nl("...on accident"); } else { putstring_nl("...on purpose"); } } else { putstring("Right wall collide"); if (! hour_changed) { putstring_nl("...on accident"); } else { putstring_nl("...on purpose"); } } } // place ball in the middle of the screen ball_x = (SCREEN_W/2 - BALL_RADIUS)*FIXED_MATH; ball_y = (SCREEN_H/2 - BALL_RADIUS)*FIXED_MATH; // TODO JMM: don't use cosine/sine... pick one randomly and calc the other one. int8_t angle = random_angle(); ball_dx = (int16_t) (((int32_t) MAX_BALL_SPEED * cosine(angle)) / 0x7FFF); ball_dy = (int16_t) (((int32_t) MAX_BALL_SPEED * sine(angle)) / 0x7FFF); glcdFillRectangle(LEFTPADDLE_X, left_keepout_top, PADDLE_W, left_keepout_bot - left_keepout_top, 0); glcdFillRectangle(RIGHTPADDLE_X, right_keepout_top, PADDLE_W, right_keepout_bot - right_keepout_top, 0); right_keepout_top = right_keepout_bot = 0; left_keepout_top = left_keepout_bot = 0; redraw_time_rat = 1; minute_changed = hour_changed = 0; ticksremaining = calculate_dest_pos(&left_dest, &right_dest, &dest_paddle_pos, ball_dx > 0); //left_score = time_h; //right_score = time_m; setscore_rat(); } // save old paddle position oldleftpaddle_y = leftpaddle_y; oldrightpaddle_y = rightpaddle_y; /* if(ball_dx > 0) { // For debugging, print the ball location DEBUG(putstring("ball @ (")); DEBUG(uart_putw_dec(ball_x)); DEBUG(putstring(", ")); DEBUG(uart_putw_dec(ball_y)); DEBUG(putstring(")")); DEBUG(putstring(" ball_dx @ (")); DEBUG(uart_putw_dec(ball_dx)); DEBUG(putstring(")")); DEBUG(putstring(" ball_dy @ (")); DEBUG(uart_putw_dec(ball_dy)); DEBUG(putstring(")")); DEBUG(putstring(" ball_dy @ (")); DEBUG(uart_putw_dec(ball_dy)); DEBUG(putstring(")")); }*/ /*if(!minute_changed) { if((ball_dx < 0) && (ball_x < (SCREEN_W/2)*FIXED_MATH)) { move_paddle(&leftpaddle_y, ball_y); } } else { //Minute changed. We now have to miss the ball on purpose, if at all possible. //If we don't succeed this time around, we will try again next time around. if((ball_dx < 0) && (ball_x < (SCREEN_W/2)*FIXED_MATH) ) { move_paddle(&leftpaddle_y, dest_paddle_pos); } }*/ //ticksremaining--; if((ball_dx < 0) && (ball_x < (SCREEN_W/2)*FIXED_MATH) ) { move_paddle(&leftpaddle_y, minute_changed?dest_paddle_pos:(ball_y-(PADDLE_H_FIXED/3))); } else if((ball_dx > 0) && (ball_x > (SCREEN_W/2)*FIXED_MATH) ) { move_paddle(&rightpaddle_y, hour_changed?dest_paddle_pos:(ball_y-(PADDLE_H_FIXED/3))); } else { if(ball_dx < 0) ticksremaining = calculate_dest_pos(&left_dest, &right_dest, &dest_paddle_pos, 1); else ticksremaining = calculate_dest_pos(&left_dest, &right_dest, &dest_paddle_pos, 0); } // make sure the paddles dont hit the top or bottom if (leftpaddle_y < TOPBAR_H_FIXED +1) leftpaddle_y = TOPBAR_H_FIXED + 1; if (rightpaddle_y < TOPBAR_H_FIXED + 1) rightpaddle_y = TOPBAR_H_FIXED + 1; if (leftpaddle_y > ((SCREEN_H - PADDLE_H - BOTBAR_H)*FIXED_MATH - 1)) leftpaddle_y = ((SCREEN_H - PADDLE_H - BOTBAR_H)*FIXED_MATH - 1); if (rightpaddle_y> ((SCREEN_H - PADDLE_H - BOTBAR_H)*FIXED_MATH - 1)) rightpaddle_y = ((SCREEN_H - PADDLE_H - BOTBAR_H)*FIXED_MATH - 1); if ((ball_dx > 0) && intersectrect(INT_MSB(ball_x), INT_MSB(ball_y), BALL_RADIUS*2, BALL_RADIUS*2, RIGHTPADDLE_X, INT_MSB(rightpaddle_y), PADDLE_W, PADDLE_H)) { ball_dx = -ball_dx; ball_x = RIGHTPADDLE_X_FIXED - (BALL_RADIUS*2*FIXED_MATH); //ball_y = right_dest; //ticksremaining = calculate_dest_pos(&left_dest, &right_dest, &dest_paddle_pos, 1); } if ((ball_dx < 0) && intersectrect(INT_MSB(ball_x), INT_MSB(ball_y), BALL_RADIUS*2, BALL_RADIUS*2, LEFTPADDLE_X, INT_MSB(leftpaddle_y), PADDLE_W, PADDLE_H)) { ball_dx = -ball_dx; ball_x = LEFTPADDLE_X_FIXED + PADDLE_W_FIXED; //ball_y = left_dest; //ticksremaining = calculate_dest_pos(&left_dest, &right_dest, &dest_paddle_pos, 0); } }
// // Function: analogAlarmAreaUpdate // // Draw update in analog clock alarm area // void analogAlarmAreaUpdate(void) { u08 inverseAlarmArea = GLCD_FALSE; u08 newAlmDisplayState = GLCD_FALSE; if ((mcCycleCounter & 0x0F) >= 8) newAlmDisplayState = GLCD_TRUE; if (mcUpdAlarmSwitch == GLCD_TRUE) { if (mcAlarmSwitch == ALARM_SWITCH_ON) { // Show alarm time in small clock s08 dxM, dyM, dxH, dyH; float radM, radH; // Prepare the analog alarm clock radM = (2L * M_PI / ANA_SECMIN_STEPS) * mcAlarmM; dxM = (s08)(sin(radM) * ANA_ALARM_MIN_RADIUS); dyM = (s08)(-cos(radM) * ANA_ALARM_MIN_RADIUS); radH = (2L * M_PI / ANA_HOUR_STEPS) * (mcAlarmH % 12) + (2L * M_PI / ANA_SECMIN_STEPS / ANA_HOUR_STEPS) * mcAlarmM; dxH = (s08)(sin(radH) * ANA_ALARM_HOUR_RADIUS); dyH = (s08)(-cos(radH) * ANA_ALARM_HOUR_RADIUS); // Clear date area glcdFillRectangle(ANA_DATE_X_START, ANA_DATE_Y_START, ANA_DATE_X_SIZE, 5, mcBgColor); // Show the alarm time glcdCircle2(ANA_ALARM_X_START, ANA_ALARM_Y_START, ANA_ALARM_RADIUS, CIRCLE_FULL, mcFgColor); glcdLine(ANA_ALARM_X_START, ANA_ALARM_Y_START, ANA_ALARM_X_START + dxM, ANA_ALARM_Y_START + dyM, mcFgColor); glcdLine(ANA_ALARM_X_START, ANA_ALARM_Y_START, ANA_ALARM_X_START + dxH, ANA_ALARM_Y_START + dyH, mcFgColor); } else { // Show date u08 pxDone = 0; char msg[4] = {0}; // Clear alarm area glcdFillRectangle(ANA_ALARM_X_START - ANA_ALARM_RADIUS - 1, ANA_ALARM_Y_START - ANA_ALARM_RADIUS - 1, ANA_ALARM_RADIUS * 2 + 3, ANA_ALARM_RADIUS * 2 + 3, mcBgColor); mcU8Util1 = GLCD_FALSE; // Show the date char *s1, *s2; #ifdef DATE_MONTHDAY s1 = (char *)months[mcClockNewDM - 1]; s2 = msg; msg[0] = ' '; animValToStr(mcClockNewDD, &(msg[1])); #else s1 = msg; s2 = (char *)months[mcClockNewDM - 1]; animValToStr(mcClockNewDD, msg); msg[2] = ' '; #endif pxDone = glcdPutStr2(ANA_DATE_X_START, ANA_DATE_Y_START, FONT_5X5P, s1, mcFgColor) + ANA_DATE_X_START; pxDone = pxDone + glcdPutStr2(pxDone, ANA_DATE_Y_START, FONT_5X5P, s2, mcFgColor) - ANA_DATE_X_START; if (pxDone <= ANA_DATE_X_SIZE) glcdFillRectangle(ANA_DATE_X_START + pxDone, ANA_DATE_Y_START, ANA_DATE_X_SIZE - pxDone + 1, FILL_BLANK, mcBgColor); } } if (mcAlarming == GLCD_TRUE) { // Blink alarm area when we're alarming or snoozing if (newAlmDisplayState != mcU8Util1) { inverseAlarmArea = GLCD_TRUE; mcU8Util1 = newAlmDisplayState; } } else { // Reset inversed alarm area when alarming has stopped if (mcU8Util1 == GLCD_TRUE) { inverseAlarmArea = GLCD_TRUE; mcU8Util1 = GLCD_FALSE; } } // Inverse the alarm area if needed if (inverseAlarmArea == GLCD_TRUE) glcdFillRectangle2(ANA_ALARM_X_START - ANA_ALARM_RADIUS - 1, ANA_ALARM_Y_START - ANA_ALARM_RADIUS - 1, ANA_ALARM_RADIUS * 2 + 3, ANA_ALARM_RADIUS * 2 + 3, ALIGN_AUTO, FILL_INVERSE, mcBgColor); }