⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scrnsaver.c

📁 ucos移植到arm_s3c2410的全套代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    t->size = t->millis * t->speed;    if (t->size > max_size) {        /* remove texture */        **prev_ptr = t->succ;        free(t);        return;    }    *prev_ptr = &t->succ;    render_texture(screen_width, screen_height, t);}static void update_all_textures(int millis){    Texture *cur;    Texture **prev_ptr;    cur = texture_list;    prev_ptr = (Texture **) &texture_list;    while (cur != NULL) {         update_texture(cur, &prev_ptr, millis);         cur = *prev_ptr;   }}static struct timeval cur_time, prev_time;static int gen_millis;static void InitFlyingGUI (void){    /* initialize */    srand(time(NULL));    banner_size(&banner_width, &banner_height);    banner_diag = sqrt(banner_width * banner_width +                              banner_height * banner_height);    screen_width  = DEFAULT_WIDTH;    screen_height = DEFAULT_HEIGHT;    gen_time = DEFAULT_GENTIME;    speed        = -1;    max_size     = -1;    cluster_size = -1;    init_textures();    if (speed < 0) {        speed = DEFAULT_SPEED;    }    if (max_size < 0) {        max_size = DEFAULT_MAXSIZE;    }    max_size = (max_size << 16) / 100;    if (cluster_size < 0) {        cluster_size = DEFAULT_CLUSTERSIZE;    }        setup_palette();    screen_diag = sqrt(screen_width  * screen_width +               screen_height * screen_height);    image_size = screen_width * screen_height * 1;    image_buf = malloc(image_size);    gettimeofday (&prev_time, NULL);    gen_millis=0;}#define CMPOPT(x,s,l,n)  (((strcmp(x,s)==0) || \               (strcmp(x,l)==0)) && ((i+n) < argc))static void OnPaint (HDC hdc){    int x, y;    int millis;    x = screen_width/2;    y = screen_width/2;    /* determine time lapse */    gettimeofday (&cur_time, NULL);    millis = (cur_time.tv_sec  - prev_time.tv_sec)  * 1000                       + (cur_time.tv_usec - prev_time.tv_usec) / 1000;    prev_time = cur_time;    if (use_putbox) {        memset(image_buf, lookup[0], image_size);    }    else {        memset(image_buf, 0,         image_size);    }    update_all_textures(millis);    update_frame (hdc);    for (gen_millis += millis; gen_millis >  gen_time;                     gen_millis -= gen_time) {        int disp_x = screen_width  * cluster_size / 200;        int disp_y = screen_height * cluster_size / 141;        x += random_in_range(-disp_x, +disp_x);        y += random_in_range(-disp_y, +disp_y);        if (x < 0) {                x += screen_width;        }        if (y < 0) {                y += screen_height;        }        if (x >= screen_width) {                x -= screen_width;        }        if (y >= screen_height) {                y -= screen_height;        }        add_texture(x, y, random_in_range(0, 255));    }}static void TermFlyingGUI (void){   free_textures();}int FlyingGUIWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam){    HDC hdc;    switch (message) {        case MSG_CREATE:            InitFlyingGUI ();#ifdef _TIMER_UNIT_10MS            SetTimer (hWnd, 100, 10);#else            SetTimer (hWnd, 100, 100);#endif        break;        case MSG_TIMER:            if (wParam == 100)                InvalidateRect (hWnd, NULL, FALSE);        break;        case MSG_PAINT:            hdc = BeginPaint (hWnd);            OnPaint (hdc);            EndPaint (hWnd, hdc);        return 0;        case MSG_CLOSE:            KillTimer (hWnd, 100);            TermFlyingGUI ();            DestroyMainWindow (hWnd);            PostQuitMessage (hWnd);        return 0;    }    return DefaultMainWinProc(hWnd, message, wParam, lParam);}static void InitCreateInfo (PMAINWINCREATE pCreateInfo){    pCreateInfo->dwStyle = WS_VISIBLE;    pCreateInfo->dwExStyle = 0;    pCreateInfo->spCaption = "Flying GUI" ;    pCreateInfo->hMenu = 0;    pCreateInfo->hCursor = 0;    pCreateInfo->hIcon = 0;    pCreateInfo->MainWindowProc = FlyingGUIWinProc;    pCreateInfo->lx = 0;     pCreateInfo->ty = 0;     pCreateInfo->rx = pCreateInfo->lx + DEFAULT_WIDTH;    pCreateInfo->by = pCreateInfo->ty + DEFAULT_HEIGHT;    pCreateInfo->iBkColor = COLOR_black;     pCreateInfo->dwAddData = 0;    pCreateInfo->hHosting = HWND_DESKTOP;}int MiniGUIMain (int args, const char* arg[]){    MSG Msg;    MAINWINCREATE CreateInfo;    HWND hMainWnd;#ifdef _LITE_VERSION    SetDesktopRect(0, 0, 1024, 768);#endif    InitCreateInfo (&CreateInfo);    hMainWnd = CreateMainWindow (&CreateInfo);    if (hMainWnd == HWND_INVALID)        return -1;    while (GetMessage (&Msg, hMainWnd)) {        DispatchMessage (&Msg);    }    MainWindowThreadCleanup (hMainWnd);    return 0;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif/* Image of GUI */static char *banner[46] = {"..................###########..................................................................................","..............###################...##.....#################..............################..###################","............########.......###########........###########....................###########........###########....","..........#######.............########.........#########......................#########..........#########.....",".........######................#######..........#######........................#######............#######......","........######...................#####..........#######........................#######............#######......",".......######.....................#####.........#######........................#######............#######......","......######......................#####.........#######........................#######............#######......",".....#######.......................####.........#######........................#######............#######......","....#######.........................###.........#######........................#######............#######......","....######..........................###.........#######........................#######............#######......","...#######..........................###.........#######........................#######............#######......","...#######...........................##.........#######........................#######............#######......","..#######.......................................#######........................#######............#######......","..#######.......................................#######........................#######............#######......",".########.......................................#######........................#######............#######......",".#######........................................#######........................#######............#######......",".#######........................................#######........................#######............#######......",".#######........................................#######........................#######............#######......","########........................................#######........................#######............#######......","########........................................#######........................#######............#######......","########..................###################...#######........................#######............#######......","########......................###########.......#######........................#######............#######......","########.......................#########........#######........................#######............#######......","########........................########........#######........................#######............#######......","########........................#######.........#######........................#######............#######......","########........................#######.........#######........................#######............#######......","#########.......................#######.........#######........................#######............#######......",".########.......................#######.........#######........................#######............#######......",".########.......................#######.........#######........................#######............#######......",".########.......................#######.........#######........................#######............#######......","..########......................#######.........#######........................#######............#######......","..########......................#######.........#######........................#######............#######......","..#########.....................#######.........#######........................#######............#######......","...########.....................#######..........#######......................#######.............#######......","....########....................#######..........#######......................#######.............#######......","....########....................#######...........#######....................#######..............#######......",".....########...................#######...........#######....................#######..............#######......","......########..................#######............#######..................#######...............#######......",".......########.................#######.............#######................#######................#######......","........########................#######..............#######..............#######.................#######......","..........########............#########...............#######............#######.................#########.....","............#########......##########..................########.........#######.................###########....","..............####################........................##################................###################","..................############...............................############......................................",NULL};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -