예제 #1
0
파일: pdcscrn.c 프로젝트: EvilTeach/Github
int PDC_color_content(short color, short *red, short *green, short *blue)
{
    *red = DIVROUND(pdc_color[color].r * 1000, 255);
    *green = DIVROUND(pdc_color[color].g * 1000, 255);
    *blue = DIVROUND(pdc_color[color].b * 1000, 255);

    return OK;
}
예제 #2
0
파일: pdcscrn.c 프로젝트: EvilTeach/Github
int PDC_init_color(short color, short red, short green, short blue)
{
    pdc_color[color].r = DIVROUND(red * 255, 1000);
    pdc_color[color].g = DIVROUND(green * 255, 1000);
    pdc_color[color].b = DIVROUND(blue * 255, 1000);

    pdc_mapped[color] = SDL_MapRGB(pdc_screen->format, pdc_color[color].r,
                                   pdc_color[color].g, pdc_color[color].b);

    wrefresh(curscr);

    return OK;
}
예제 #3
0
파일: pdcscrn.c 프로젝트: wmcbrine/PDCurses
int PDC_init_color(short color, short red, short green, short blue)
{
    if (color < 16)
    {
        COLORREF *color_table = _get_colors();

        if (color_table)
        {
            color_table[pdc_curstoreal[color]] =
                RGB(DIVROUND(red * 255, 1000),
                    DIVROUND(green * 255, 1000),
                    DIVROUND(blue * 255, 1000));

            return _set_colors();
        }
    }

    return ERR;
}
예제 #4
0
파일: pdcscrn.c 프로젝트: wmcbrine/PDCurses
int PDC_color_content(short color, short *red, short *green, short *blue)
{
    if (color < 16)
    {
        COLORREF *color_table = _get_colors();

        if (color_table)
        {
            DWORD col = color_table[pdc_curstoreal[color]];

            *red = DIVROUND(GetRValue(col) * 1000, 255);
            *green = DIVROUND(GetGValue(col) * 1000, 255);
            *blue = DIVROUND(GetBValue(col) * 1000, 255);

            return OK;
        }
    }

    return ERR;
}
예제 #5
0
파일: bitset.c 프로젝트: thumphries/aos
int bitset_ffz(bitset *bs) {
    if (bs == NULL) return 0;
    int i;
    unsigned int pos = 0;
    int nwords = DIVROUND(bs->size, sizeof(unsigned int));
    unsigned int *words = (unsigned int *) bs->bs;
    for (i = 0; i < nwords; i++) {
        pos = ffs(~words[i]);
        if (pos) {
            break;
        }
    }

    pos += (i * nwords) - 1;
    return pos <= bs->size ? pos : -1;
}
예제 #6
0
파일: ttyout.c 프로젝트: thumphries/aos
/* Attempt writes until everything is written */
size_t sos_write(void *vData, size_t count) {
    seL4_Word *data;
    seL4_Word woffset;
    size_t bleft;

    seL4_Word *alldata = vData;
    size_t written = 0;

    while (written < count) {
      /* Adjust 'data' pointer and number of remaining bytes */
      woffset = DIVROUND(written, 4);
      data = alldata + woffset;
      bleft = count - written;

      /* Attempt to write remainder */
      written += _sos_write(data, bleft);
    }
 
    return written;
}
예제 #7
0
파일: ttyout.c 프로젝트: thumphries/aos
/* Attempt single write, without retrying */
size_t _sos_write(void *vData, size_t count) {
    seL4_Word *realdata = (seL4_Word*) vData;
    seL4_IPCBuffer *buf = seL4_GetIPCBuffer();
    seL4_Word len = 2 + DIVROUND(count, 4);
    seL4_Word real_len = MIN(seL4_MsgMaxLength, len);
    size_t real_count  = MIN(count, (seL4_MsgMaxLength - 2) * 4);

    /* Set up syscall parameters */
    buf->msg[0] = SOS_SYSCALL_WRITE_CONSOLE;
    buf->msg[1] = real_count;

    int i;
    for (i = 2; i < len; i++) {
      buf->msg[i] = realdata[i - 2];
    }

    /* Fire off syscall and wait for reply */
    seL4_MessageInfo_t tag = seL4_MessageInfo_new(0, 0, 0, real_len);
    seL4_Call(SYSCALL_ENDPOINT_SLOT, tag);

    return seL4_GetMR(0);
}