<1>/* Graphics Not Rendered in HTML */











#define STRING_CENTER_X_OFFSET  1
#define STRING_CENTER_Y_OFFSET  80
#define DISPLAY_RECT_HEIGHT 8
#define WIN_TOP     TEXT_ROWS / 3   // each 1 represents
#define WIN_LEFT    TEXT_COLS / 3   // 8 pixels.

DefineListLoad("ST_MOTTOS", "Divine Intellect Inside\0"
                            "Professional Recreation\0"
                            "Programming Enlightenment\0"
                            "LoseThos Resurrected\0"
                            "Unrestricted Potential\0"
                            "Ring-0 64-Bit Operating System\0"
                            "Simplicity Perfected\0");

Sleep((Now + counts.timer) & 0x7F); // increase entropy of motto selection

U8* display_string  = MStrPrint("%S", "DD_OS_NAME_VERSION");
U8* motto_string    = MStrPrint("%Z", RandU8 % DefineCount("ST_MOTTOS"), "ST_MOTTOS");
I64 display_string_offset   = StrLen(display_string) / 2 * 8 - STRING_CENTER_X_OFFSET;
I64 motto_string_offset     = StrLen(motto_string) / 2 * 8;
I64 splash_r[4][4];

U0 DrawIt(CTask *,CDC *dc)
{
    I64 *old_r = dc->r;
    I64  screen_center_x_pix = GR_WIDTH / 2;        // each 1 represents
    I64  screen_center_y_pix = (GR_HEIGHT / 2); // single pixels.

    dc->x = screen_center_x_pix - (WIN_LEFT * 8);   // to plot in the center, we put dc at the screen center in pixels, 
    dc->y = screen_center_y_pix - (WIN_TOP * 8);    // minus the window position (times 8 since win row/col variables are 1:8 ratio.)
    dc->z = GR_Z_ALL;                               // the result is the position in the current window that aligns to center of screen.

    dc->flags |= DCF_TRANSFORMATION;
    DCDepthBufAlloc(dc);
    DCMat4x4Set(dc, splash_r); //This assigns to dc->r and sets r_norm.
    DCDepthBufReset(dc);

    Sprite3(dc, 0, 0, 0, <1>); // plot the sprite directly at the position of dc.

    dc->color = LTGRAY;
    GrRect(dc, dc->x - display_string_offset, dc->y - STRING_CENTER_Y_OFFSET, StrLen(display_string) * 8, DISPLAY_RECT_HEIGHT);
    dc->color = BLACK;
    GrPrint(dc, dc->x - display_string_offset, dc->y - STRING_CENTER_Y_OFFSET, display_string);

    dc->color = LTGRAY;
    GrRect(dc, dc->x - motto_string_offset, dc->y + STRING_CENTER_Y_OFFSET, StrLen(motto_string) * 8, DISPLAY_RECT_HEIGHT);
    dc->color = BLACK;
    GrPrint(dc, dc->x - motto_string_offset, dc->y + STRING_CENTER_Y_OFFSET, motto_string);

    dc->r = old_r;
}

U0 DrawNoMouse(CDC *dc,I64 x,I64 y)
{
    no_warn dc, x, y;
}

U0 ZSplash()
{
    F64      theta = 0.3, phi = 0;
    CTask   *bg_task = User;

    WinToTop(bg_task);
    WinBorder(, bg_task);
    WinMax(bg_task);
    DocClear(bg_task->put_doc);
    Bts(&bg_task->put_doc->flags, DOCf_HIDE_CURSOR);
    AutoComplete(OFF);

    WinToTop;

    Fs->win_top     = WIN_TOP;
    Fs->win_left    = WIN_LEFT;
    Fs->win_right   = WIN_LEFT * 2;
    Fs->win_bottom  = WIN_TOP  * 2;

    Fs->draw_it = &DrawIt;

    DocClear(Fs->border_doc, TRUE);

    StrCopy(Fs->task_title, display_string);

    gr.fp_draw_mouse = &DrawNoMouse;

    Bts(&Fs->put_doc->flags, DOCf_HIDE_CURSOR);
    MouseHardEnable(FALSE);

    while (!CharScan)
    {
        Mat4x4IdentEqu(splash_r);
        Mat4x4RotY(splash_r, phi);
        Mat4x4RotX(splash_r, theta);

        Sleep(20);
        phi += .03;
        WinToTop;
    }

    gr.fp_draw_mouse = &DrawStdMouse;
    MouseHardEnable(TRUE);
    FlushMessages;
    Kill(bg_task);
    AutoComplete(ON);
}

ZSplash;