/* Draws sky with sun background */ void draw_sky(alt_up_pixel_buffer_dma_dev* pixel_buffer){ int color_inc = 0x0001; int x0_pos = 0; int x1_pos = 320; int change = 4; int y_pos; // Draws sky for(y_pos = 0; y_pos < 45; y_pos++) { alt_up_pixel_buffer_dma_draw_hline(pixel_buffer, x0_pos, x1_pos, y_pos, 0xF800 + color_inc, 0); if(y_pos % 3 == 0) color_inc++; } x0_pos = 155; x1_pos = 165; // Draws sun for(y_pos = 37; y_pos < 45; y_pos++) { alt_up_pixel_buffer_dma_draw_hline(pixel_buffer, x0_pos, x1_pos, y_pos, ORANGE, 0); if(y_pos == 37 || y_pos == 39) change = 4; else if(y_pos == 38) change = 3; else change = 1; x0_pos -= change; x1_pos += change; } }
void draw_boardwalk(alt_up_pixel_buffer_dma_dev* pixel_buffer) { int i; alt_up_pixel_buffer_dma_draw_box(pixel_buffer, 0, 45, 14, 240, 0x79E5, 0); for(i = 45; i < 240; i+=4 ) { alt_up_pixel_buffer_dma_draw_hline(pixel_buffer, 0, 14, i, BLACK, 0); } }
void draw_qnote_on_sheetmusic(alt_up_pixel_buffer_dma_dev * pixel_buffer, int pitch, int location) // FUNCTION: Draws a quarter note with the given pitch at the given location to the back buffer // REQUIRES: 0 <= pitch <= 7 && 0 <= location <= 15 // RETURNS: None { // Symbolic constants int h_spacing = 18; int first_note_left = 21; int lowc_bottom = 153; // Declare variables int left, right, top, bottom; left = first_note_left + location*h_spacing; right = left + 8; bottom = lowc_bottom - 5*pitch; top = bottom - 6; // Draw note with stem alt_up_pixel_buffer_dma_draw_box(pixel_buffer, left, bottom, right, top, 0x0000, 1); if(pitch<6) // Draw stem extending upwards alt_up_pixel_buffer_dma_draw_vline(pixel_buffer, right, top, top-32, 0x0000, 1); else // Draw stem extending downwards alt_up_pixel_buffer_dma_draw_vline(pixel_buffer, left, bottom, bottom+32, 0x0000, 1); // Check if the pitch is low C, and if so draw an extra horizontal line if(pitch==0) alt_up_pixel_buffer_dma_draw_hline(pixel_buffer, left-3, right+3, bottom-3, 0x0000, 1); }
void prepareBackground(void){ alt_up_pixel_buffer_dma_clear_screen(pixel_buffer_dev, backbuffer); //Clear the backbuffer //Main lines alt_up_pixel_buffer_dma_draw_box(pixel_buffer_dev, 0, 0, 319, 239, BACKGROUNDCOLOR, backbuffer); //Make the backbuffer the correct color alt_up_pixel_buffer_dma_draw_hline(pixel_buffer_dev, 12, 319, 226,SYSLINECOLOR, backbuffer); //Draw the horizontal sysline to the backbuffer alt_up_pixel_buffer_dma_draw_vline(pixel_buffer_dev, 12, 0, 226,SYSLINECOLOR, backbuffer); //Draw the vertical line }
void draw_correct_zone(alt_up_pixel_buffer_dma_dev* pixel_buffer, int CORRECT_ZONE_HEIGHT) // FUNCTION: Draws the correct zone for the note game // REQUIRES: 1 <= CORRECT_ZONE_HEIGHT <= 50 // RETURNS: None { int i; alt_up_pixel_buffer_dma_draw_hline(pixel_buffer, 0, 319, 220-4*CORRECT_ZONE_HEIGHT, 0x0000, 1); // Top of the correct zone for(i=0; i<320; i++) { alt_up_pixel_buffer_dma_draw_vline(pixel_buffer, i, 221-4*CORRECT_ZONE_HEIGHT, 219, 0xCCCC, 1); } alt_up_pixel_buffer_dma_draw_hline(pixel_buffer, 0, 319, 220, 0x0000, 1); // Bottom of the correct zone }
void eraser_rb(alt_up_pixel_buffer_dma_dev* pixel_buffer, int location, int x_location, int CORRECT_ZONE_HEIGHT) // FUNCTION: Draws over the note at the given location in the appropriate background colour to the backbuffer // REQUIRES: 1 <= location <= 60 && 1 <= x_location <= 80 && 1 <= CORRECT_ZONE_HEIGHT <= 50 // RETURNS: None { if(location < 55 - CORRECT_ZONE_HEIGHT - 2) // location is completely outside of correct zone. Erase in blue background colour. { #if 1 // Draw double thickness square in blue background colour alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, x_location*4 - 9, location*4 - 12, x_location*4 + 11, location*4 + 8,0x122B, 1); alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, x_location*4 - 8, location*4 - 11, x_location*4 + 10, location*4 + 7,0x122B, 1); alt_up_pixel_buffer_dma_draw_box(pixel_buffer, x_location*4 - 9, location*4 - 16, x_location*4 + 11, location*4 - 13,0x122B, 1); #endif #if 0 alt_up_pixel_buffer_dma_draw_box(pixel_buffer, x_location*4 - 9, location*4 - 16, x_location*4 + 11, location*4 + 10,0x122B, 1); #endif } else // Some overlap with correct zone. Redraw a portion of the correct zone { #if 1 // Draw double thickness square in blue background colour alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, x_location*4 - 9, location*4 - 12, x_location*4 + 11, location*4 + 8,0x122B, 1); alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, x_location*4 - 8, location*4 - 11, x_location*4 + 10, location*4 + 7,0x122B, 1); alt_up_pixel_buffer_dma_draw_box(pixel_buffer, x_location*4 - 9, location*4 - 16, x_location*4 + 11, location*4 - 13,0x122B, 1); #endif #if 0 // alt_up_pixel_buffer_dma_draw_box(pixel_buffer, x_location*4 - 9, location*4 - 16, x_location*4 + 11, location*4 + 10,0x122B, 1); #endif alt_up_pixel_buffer_dma_draw_hline(pixel_buffer, x_location*4 - 9, x_location*4 + 11, 220-4*CORRECT_ZONE_HEIGHT, 0x0000, 1); // Top of the correct zone alt_up_pixel_buffer_dma_draw_box(pixel_buffer, x_location*4 - 9, 221-4*CORRECT_ZONE_HEIGHT, x_location*4 + 11, 219, 0xCCCC, 1); // Correct zone alt_up_pixel_buffer_dma_draw_hline(pixel_buffer, x_location*4 - 9, x_location*4 + 11, 220, 0x0000, 1); // Bottom of the correct zone } }
void drawHelpLines(void){ //Redraw the indicationlines //Smaller lines(horizontal) int tPos; for (tPos = 0; tPos < 228; tPos +=46){ alt_up_pixel_buffer_dma_draw_hline(pixel_buffer_dev, 12, 15, tPos,SYSLINECOLOR, backbuffer); //Draw a small horizontal line for indication } //Smaller lines (vertical) for (tPos = 319; tPos > 31; tPos -=31){ alt_up_pixel_buffer_dma_draw_vline(pixel_buffer_dev, tPos, 223, 226,SYSLINECOLOR, backbuffer); //Draw a small vertical line for indication } }
/* Draws bullet with background color */ void draw_background_bullet(alt_up_pixel_buffer_dma_dev* pixel_buffer, int x_start, int y_start) { int color_inc = 1; int i; for(i = 45; i < y_start; i++) { if(i%8 == 0) color_inc++; } for(i = y_start; i <= y_start + 2; i++) { alt_up_pixel_buffer_dma_draw_hline(pixel_buffer, x_start, x_start+12, i, BLACK + color_inc, 0); if(i % 8 == 0) { color_inc++; } } }
void draw_sheetmusic() { // Symbolic constants int x_indent = 16; int y_indent = 100; int space_height = (240 - 2*y_indent)/4; // Declare variables int i; if(m == blank) { rb.background_flag = FALSE; if(v.blank_flag == FALSE) { alt_up_pixel_buffer_dma_draw_box(v.pixel_buffer, 0, 0, 319, 239, 0xFFFF, 1); // White box to fill the back buffer for(i=0; i<5; i++) // Draw 5 horizontal lines of the musical staff to the back buffer alt_up_pixel_buffer_dma_draw_hline(v.pixel_buffer, x_indent-2, 320-(x_indent-2), y_indent+space_height*i, 0x0000, 1); // Double bar line at the start alt_up_pixel_buffer_dma_draw_box(v.pixel_buffer, x_indent-4, y_indent, x_indent-2, 240-y_indent, 0x0000, 1); alt_up_pixel_buffer_dma_draw_vline(v.pixel_buffer, x_indent, y_indent, 240-y_indent, 0x0000, 1); // Double bar line at the end alt_up_pixel_buffer_dma_draw_box(v.pixel_buffer, 320-(x_indent-4), y_indent, 320-(x_indent-2), 240-y_indent, 0x0000, 1); alt_up_pixel_buffer_dma_draw_vline(v.pixel_buffer, 320-x_indent, y_indent, 240-y_indent, 0x0000, 1); // Three bar lines to divide the staff into four measures alt_up_pixel_buffer_dma_draw_vline(v.pixel_buffer, (160+x_indent)/2, y_indent, 240-y_indent, 0x0000, 1); alt_up_pixel_buffer_dma_draw_vline(v.pixel_buffer, 160, y_indent, 240-y_indent, 0x0000, 1); alt_up_pixel_buffer_dma_draw_vline(v.pixel_buffer, (480-x_indent)/2, y_indent, 240-y_indent, 0x0000, 1); // Draw some notes: C major scale draw_qnote_on_sheetmusic(v.pixel_buffer, 0, 0); draw_qnote_on_sheetmusic(v.pixel_buffer, 1, 1); draw_qnote_on_sheetmusic(v.pixel_buffer, 2, 2); draw_qnote_on_sheetmusic(v.pixel_buffer, 3, 3); draw_qnote_on_sheetmusic(v.pixel_buffer, 4, 4); draw_qnote_on_sheetmusic(v.pixel_buffer, 5, 5); draw_qnote_on_sheetmusic(v.pixel_buffer, 6, 6); draw_qnote_on_sheetmusic(v.pixel_buffer, 7, 7); draw_qnote_on_sheetmusic(v.pixel_buffer, 7, 8); draw_qnote_on_sheetmusic(v.pixel_buffer, 6, 9); draw_qnote_on_sheetmusic(v.pixel_buffer, 5, 10); draw_qnote_on_sheetmusic(v.pixel_buffer, 4, 11); draw_qnote_on_sheetmusic(v.pixel_buffer, 3, 12); draw_qnote_on_sheetmusic(v.pixel_buffer, 2, 13); draw_qnote_on_sheetmusic(v.pixel_buffer, 1, 14); draw_qnote_on_sheetmusic(v.pixel_buffer, 0, 15); // Blue box and message near top of the screen alt_up_pixel_buffer_dma_draw_box(v.pixel_buffer, 100, 26, 220, 40, 0x122B, 1); alt_up_char_buffer_clear(v.char_buffer); alt_up_char_buffer_string(v.char_buffer, "Waiting for user input...", 28, 8); v.blank_flag = TRUE; // Swap buffers alt_up_pixel_buffer_dma_swap_buffers(v.pixel_buffer); while (alt_up_pixel_buffer_dma_check_swap_buffers_status(v.pixel_buffer)); } } }