|
PatchworkOS
|
#include <errno.h>#include <libpatchwork/patchwork.h>#include <stdbool.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/proc.h>Go to the source code of this file.
Typedefs | |
| typedef block_t | piece_t[PIECE_HEIGHT][PIECE_WIDTH] |
Enumerations | |
| enum | block_t { BLOCK_INVAL , BLOCK_NONE , BLOCK_CYAN , BLOCK_BLUE , BLOCK_ORANGE , BLOCK_YELLOW , BLOCK_GREEN , BLOCK_PURPLE , BLOCK_RED , BLOCK_CLEARING , BLOCK_OUTLINE } |
| enum | piece_type_t { PIECE_NONE , PIECE_CYAN , PIECE_BLUE , PIECE_ORANGE , PIECE_YELLOW , PIECE_GREEN , PIECE_PURPLE , PIECE_RED } |
Variables | ||
| static element_t * | currentScoreLabel | |
| static element_t * | completeLinesLabel | |
| static element_t * | playedBlocksLabel | |
| static piece_t | pieces [] | |
| static block_t | field [FIELD_HEIGHT][FIELD_WIDTH] | |
| static block_t | oldField [FIELD_HEIGHT][FIELD_WIDTH] | |
| static uint64_t | currentScore | |
| static uint64_t | completedLines | |
| static uint64_t | playedBlocks | |
| static uint64_t | oldCurrentScore | |
| static uint64_t | oldCompletedLines | |
| static uint64_t | oldPlayedBlocks | |
| static bool | isClearingLines | |
| static bool | isStarted | |
| static bool | isGameover | |
| static font_t * | largeFont | |
| static font_t * | massiveFont | |
| struct { | ||
| piece_t piece | ||
| int64_t x | ||
| int64_t y | ||
| bool isDropping | ||
| } | currentPiece | |
| static const pixel_t | normalColors [] | |
| static const pixel_t | highlightColors [] | |
| static const pixel_t | shadowColors [] | |
| #define CLEARING_LINES_TICK_SPEED (CLOCKS_PER_SEC / 15) |
| #define DROPPING_TICK_SPEED (CLOCKS_PER_SEC / 12) |
| #define FIELD_BOTTOM (FIELD_PADDING + BLOCK_SIZE * FIELD_HEIGHT) |
| #define FIELD_LEFT (FIELD_PADDING) |
| #define FIELD_RIGHT (FIELD_PADDING + BLOCK_SIZE * FIELD_WIDTH) |
| #define FIELD_TOP (FIELD_PADDING) |
| #define SIDE_PANEL_BOTTOM (FIELD_BOTTOM) |
| #define SIDE_PANEL_LEFT (FIELD_RIGHT + FIELD_PADDING) |
| #define SIDE_PANEL_RIGHT (SIDE_PANEL_LEFT + SIDE_PANEL_WIDTH - FIELD_PADDING) |
| #define START_SCREEN_TICK_SPEED ((CLOCKS_PER_SEC / 4) * 3) |
| #define TICK_SPEED (CLOCKS_PER_SEC) |
| #define WINDOW_HEIGHT ((FIELD_HEIGHT) * BLOCK_SIZE + FIELD_PADDING * 2) |
| #define WINDOW_WIDTH ((FIELD_WIDTH) * BLOCK_SIZE + FIELD_PADDING * 2 + SIDE_PANEL_WIDTH) |
| typedef block_t piece_t[PIECE_HEIGHT][PIECE_WIDTH] |
| enum block_t |
| enum piece_type_t |
|
static |
Definition at line 198 of file main.c.
References BLOCK_SIZE, draw_frame(), draw_rect(), element_get_theme(), FIELD_HEIGHT, FIELD_LEFT, FIELD_TOP, FIELD_WIDTH, theme_t::frameSize, highlightColors, normalColors, RECT_INIT_DIM, RECT_SHRINK, shadowColors, theme, x, and y.
Referenced by field_draw(), piece_clear(), piece_draw(), and piece_outline_draw().
|
static |
Definition at line 566 of file main.c.
References currentPiece, field_collides(), isGameover, memcpy(), pause(), PIECE_AMOUNT, pieces, playedBlocks, and rand().
Referenced by current_piece_update(), and start().
|
static |
Definition at line 581 of file main.c.
References currentPiece, field_collides(), piece_clear(), and piece_is_out_of_bounds().
Referenced by current_piece_drop(), current_piece_move(), current_piece_rotate(), current_piece_update(), and field_clear_lines().
|
static |
Definition at line 595 of file main.c.
References currentPiece, field_collides(), piece_draw(), piece_is_out_of_bounds(), and piece_outline_draw().
Referenced by current_piece_drop(), current_piece_move(), current_piece_rotate(), current_piece_update(), and field_clear_lines().
|
static |
Definition at line 642 of file main.c.
References current_piece_clear(), current_piece_draw(), currentPiece, field_collides(), and piece_is_out_of_bounds().
Referenced by procedure().
|
static |
Definition at line 627 of file main.c.
References current_piece_clear(), current_piece_draw(), currentPiece, field_collides(), KBD_A, KBD_D, and piece_is_out_of_bounds().
Referenced by procedure().
|
static |
Definition at line 656 of file main.c.
References current_piece_clear(), current_piece_draw(), currentPiece, field_collides(), memcpy(), piece_is_out_of_bounds(), and piece_rotate().
Referenced by procedure().
|
static |
Definition at line 609 of file main.c.
References current_piece_choose_new(), current_piece_clear(), current_piece_draw(), currentPiece, field_add_piece(), field_check_for_lines(), field_collides(), and piece_is_out_of_bounds().
Referenced by procedure().
Definition at line 398 of file main.c.
References BLOCK_NONE, currentPiece, field, piece, piece_block_pos_in_field(), PIECE_HEIGHT, PIECE_WIDTH, point_t::x, and point_t::y.
Referenced by current_piece_update().
|
static |
Definition at line 471 of file main.c.
References BLOCK_CLEARING, BLOCK_NONE, completedLines, currentScore, field, field_draw(), FIELD_HEIGHT, FIELD_WIDTH, isClearingLines, x, and y.
Referenced by current_piece_update().
|
static |
Definition at line 428 of file main.c.
References BLOCK_CLEARING, BLOCK_NONE, current_piece_clear(), current_piece_draw(), field, field_draw(), FIELD_HEIGHT, field_move_down(), FIELD_WIDTH, isClearingLines, x, and y.
Referenced by procedure().
Definition at line 372 of file main.c.
References BLOCK_NONE, field, FIELD_HEIGHT, FIELD_WIDTH, piece, piece_block_pos_in_field(), PIECE_HEIGHT, PIECE_WIDTH, point_t::x, and point_t::y.
Referenced by current_piece_choose_new(), current_piece_clear(), current_piece_draw(), current_piece_drop(), current_piece_move(), current_piece_rotate(), and current_piece_update().
|
static |
Definition at line 355 of file main.c.
References block_draw(), field, FIELD_HEIGHT, FIELD_WIDTH, oldField, x, and y.
Referenced by field_check_for_lines(), field_clear_lines(), and procedure().
|
static |
Definition at line 344 of file main.c.
References theme_color_set_t::backgroundNormal, theme_t::deco, draw_bezel(), draw_frame(), element_get_theme(), FIELD_BOTTOM, FIELD_LEFT, FIELD_PADDING, FIELD_RIGHT, FIELD_TOP, theme_t::frameSize, theme_color_set_t::highlight, RECT_EXPAND, RECT_INIT, RECT_SHRINK, theme_color_set_t::shadow, and theme.
Referenced by procedure().
|
static |
Definition at line 415 of file main.c.
References BLOCK_NONE, field, FIELD_WIDTH, memcpy(), x, and y.
Referenced by field_clear_lines().
| int main | ( | void | ) |
Definition at line 896 of file main.c.
References CLOCKS_NEVER, display_dispatch(), display_free(), display_new(), display_next(), ERR, EXIT_FAILURE, EXIT_SUCCESS, font_free(), font_new(), largeFont, massiveFont, NULL, procedure(), RECT_INIT_DIM, SURFACE_WINDOW, WINDOW_DECO, window_free(), WINDOW_HEIGHT, window_new(), window_set_visible(), and WINDOW_WIDTH.
|
static |
Definition at line 525 of file main.c.
References BLOCK_INVAL, BLOCK_NONE, field, FIELD_HEIGHT, FIELD_WIDTH, isClearingLines, isGameover, isStarted, oldField, x, and y.
Referenced by current_piece_choose_new(), and procedure().
|
static |
Definition at line 249 of file main.c.
References PIECE_HEIGHT, PIECE_WIDTH, and point_t::x.
Referenced by field_add_piece(), field_collides(), piece_clear(), piece_draw(), piece_is_out_of_bounds(), and piece_outline_draw().
|
static |
Definition at line 277 of file main.c.
References block_draw(), BLOCK_NONE, piece, piece_block_pos_in_field(), PIECE_HEIGHT, PIECE_WIDTH, point_t::x, and point_t::y.
Referenced by current_piece_clear().
|
static |
Definition at line 312 of file main.c.
References block_draw(), BLOCK_NONE, piece, piece_block_pos_in_field(), PIECE_HEIGHT, PIECE_WIDTH, point_t::x, and point_t::y.
Referenced by current_piece_draw().
Definition at line 254 of file main.c.
References BLOCK_NONE, FIELD_HEIGHT, FIELD_WIDTH, piece, piece_block_pos_in_field(), PIECE_HEIGHT, PIECE_WIDTH, point_t::x, and point_t::y.
Referenced by current_piece_clear(), current_piece_draw(), current_piece_drop(), current_piece_move(), current_piece_rotate(), and current_piece_update().
|
static |
Definition at line 294 of file main.c.
References block_draw(), BLOCK_NONE, BLOCK_OUTLINE, piece, piece_block_pos_in_field(), PIECE_HEIGHT, PIECE_WIDTH, point_t::x, and point_t::y.
Referenced by current_piece_draw().
|
static |
Definition at line 329 of file main.c.
Referenced by current_piece_rotate().
Definition at line 717 of file main.c.
References theme_color_set_t::backgroundNormal, rect_t::bottom, buffer, CLEARING_LINES_TICK_SPEED, event_kbd_t::code, COMPLETE_LINES_LABEL_ID, completedLines, completeLinesLabel, current_piece_drop(), current_piece_move(), current_piece_rotate(), current_piece_update(), CURRENT_SCORE_LABEL_ID, currentPiece, currentScore, currentScoreLabel, display_disconnect(), DROPPING_TICK_SPEED, element_draw_begin(), element_draw_end(), element_get_text_props(), element_get_theme(), ELEMENT_NONE, element_redraw(), element_set_text(), EVENT_KBD, EVENT_TIMER, field_clear_lines(), field_draw(), field_edge_draw(), text_props_t::font, theme_color_set_t::foregroundNormal, isClearingLines, isGameover, isStarted, event_t::kbd, KBD_A, KBD_D, KBD_PRESS, KBD_R, KBD_RELEASE, KBD_S, KBD_SPACE, label_new(), largeFont, LEVENT_INIT, LEVENT_QUIT, LEVENT_REDRAW, oldCompletedLines, oldCurrentScore, oldPlayedBlocks, pause(), PLAYED_BLOCKS_LABEL_ID, playedBlocks, playedBlocksLabel, RECT_INIT, side_panel_draw(), SIDE_PANEL_LABEL_HEIGHT, SIDE_PANEL_LABEL_PADDING, SIDE_PANEL_LEFT, SIDE_PANEL_RIGHT, SIDE_PANEL_TEXT_HEIGHT, SIDE_PANEL_TOP, sprintf(), srand(), start(), start_press_space_draw(), START_SCREEN_TICK_SPEED, start_tetris_draw(), theme, TICK_SPEED, TIMER_NONE, rect_t::top, event_kbd_t::type, event_t::type, uptime(), theme_t::view, window_get_display(), and window_set_timer().
|
static |
Definition at line 216 of file main.c.
References ALIGN_CENTER, rect_t::bottom, theme_t::deco, draw_ridge(), draw_text(), element_get_theme(), font_height(), theme_color_set_t::foregroundNormal, theme_t::frameSize, theme_color_set_t::highlight, largeFont, RECT_INIT, theme_color_set_t::shadow, SIDE_PANEL_BOTTOM, SIDE_PANEL_LABEL_HEIGHT, SIDE_PANEL_LEFT, SIDE_PANEL_RIGHT, SIDE_PANEL_TEXT_HEIGHT, SIDE_PANEL_TOP, theme, rect_t::top, and theme_t::view.
Referenced by procedure().
|
static |
Definition at line 542 of file main.c.
References BLOCK_INVAL, BLOCK_NONE, completedLines, current_piece_choose_new(), currentPiece, currentScore, field, FIELD_HEIGHT, FIELD_WIDTH, isClearingLines, isGameover, isStarted, oldField, playedBlocks, x, and y.
Referenced by aml_debug_dump(), aml_debug_dump_print_line(), aml_debug_error(), aml_def_bank_field_read(), aml_def_buffer_read(), aml_def_device_read(), aml_def_else_read(), aml_def_field_read(), aml_def_if_else_read(), aml_def_index_field_read(), aml_def_method_read(), aml_def_package_read(), aml_def_power_res_read(), aml_def_processor_read(), aml_def_scope_read(), aml_def_thermal_zone_read(), aml_def_var_package_read(), aml_def_while_read(), aml_dual_name_path_read(), aml_method_set(), aml_multi_name_path_read(), aml_name_seg_read(), aml_namespace_add_by_name_string(), aml_namespace_find(), aml_namespace_find_by_name_string(), aml_namespace_find_by_path(), aml_parse(), aml_pkg_length_read(), aml_string_read(), aml_term_list_read(), benchmark(), benchmark_mmap(), config_get_array(), count_primes(), dentry_generic_getdents(), draw_gradient(), draw_line(), getdents_write(), hpet_wait(), lltoa(), panic_symbols_init(), path_walk(), path_walk_parent(), procedure(), rwlock_read_acquire(), rwlock_write_acquire(), space_map_kernel_space_region(), space_unmap_kernel_space_region(), start_services(), thrd_sleep(), and thread_entry().
|
static |
Definition at line 703 of file main.c.
References ALIGN_CENTER, BLOCK_NONE, theme_t::deco, draw_rect(), draw_text(), element_get_theme(), FIELD_BOTTOM, FIELD_LEFT, FIELD_RIGHT, FIELD_TOP, theme_color_set_t::foregroundNormal, largeFont, normalColors, RECT_INIT, and theme.
Referenced by procedure().
|
static |
Definition at line 673 of file main.c.
References ALIGN_CENTER, BLOCK_BLUE, BLOCK_CYAN, BLOCK_GREEN, BLOCK_ORANGE, BLOCK_RED, BLOCK_YELLOW, draw_text(), FIELD_BOTTOM, FIELD_LEFT, FIELD_RIGHT, FIELD_TOP, font_width(), rect_t::left, massiveFont, normalColors, RECT_INIT, and rect_t::right.
Referenced by procedure().
|
static |
Definition at line 135 of file main.c.
Referenced by field_check_for_lines(), procedure(), and start().
|
static |
Definition at line 47 of file main.c.
Referenced by procedure().
| struct { ... } currentPiece |
|
static |
Definition at line 134 of file main.c.
Referenced by field_check_for_lines(), procedure(), and start().
|
static |
Definition at line 46 of file main.c.
Referenced by procedure().
|
static |
Definition at line 131 of file main.c.
Referenced by field_add_piece(), field_check_for_lines(), field_clear_lines(), field_collides(), field_draw(), field_move_down(), pause(), and start().
|
static |
Definition at line 169 of file main.c.
Referenced by block_draw().
|
static |
Definition at line 142 of file main.c.
Referenced by field_check_for_lines(), field_clear_lines(), pause(), procedure(), and start().
|
static |
Definition at line 144 of file main.c.
Referenced by current_piece_choose_new(), pause(), procedure(), and start().
|
static |
Definition at line 143 of file main.c.
Referenced by pause(), procedure(), and start().
|
static |
Definition at line 146 of file main.c.
Referenced by main(), procedure(), side_panel_draw(), and start_press_space_draw().
|
static |
Definition at line 147 of file main.c.
Referenced by main(), and start_tetris_draw().
|
static |
Definition at line 157 of file main.c.
Referenced by block_draw(), start_press_space_draw(), and start_tetris_draw().
|
static |
Definition at line 139 of file main.c.
Referenced by procedure().
|
static |
Definition at line 138 of file main.c.
Referenced by procedure().
|
static |
Definition at line 132 of file main.c.
Referenced by field_draw(), pause(), and start().
|
static |
Definition at line 140 of file main.c.
Referenced by procedure().
| piece_t piece |
Definition at line 151 of file main.c.
Referenced by field_add_piece(), field_collides(), piece_clear(), piece_draw(), piece_is_out_of_bounds(), and piece_outline_draw().
|
static |
Definition at line 79 of file main.c.
Referenced by current_piece_choose_new().
|
static |
Definition at line 136 of file main.c.
Referenced by current_piece_choose_new(), procedure(), and start().
|
static |
Definition at line 48 of file main.c.
Referenced by procedure().
|
static |
Definition at line 181 of file main.c.
Referenced by block_draw().
| int64_t x |
Definition at line 152 of file main.c.
Referenced by _strtoll_main(), aml_round_up_to_power_of_two(), atan(), atan2(), atoll(), block_draw(), ceil(), cos(), draw_dashed_outline(), draw_frame(), draw_gradient(), draw_grf_char(), draw_polygon(), draw_transfer_blend(), field_check_for_lines(), field_clear_lines(), field_draw(), field_move_down(), floor(), fmod(), modf(), panic_without_boot_services(), pause(), round(), screen_transfer_blend(), sin(), start(), and trunc().
| int64_t y |
Definition at line 153 of file main.c.
Referenced by _time_day_of_week(), atan2(), block_draw(), draw_dashed_outline(), draw_frame(), draw_gradient(), draw_grf_char(), draw_polygon(), draw_rect(), draw_transfer(), draw_transfer_blend(), field_check_for_lines(), field_clear_lines(), field_draw(), field_move_down(), fmod(), log_screen_clear(), log_screen_flush(), log_screen_get_line(), log_screen_put(), log_screen_scroll(), mktime(), panic_without_boot_services(), pause(), procedure(), screen_swap(), screen_transfer(), screen_transfer_blend(), screen_transfer_frontbuffer(), and start().