112 lines · 1.9 KB · C
RawDownload
#include "u.h"#include "lib.h"#include "dat.h"#include "fns.h"//#include "error.h" #include <draw.h>#include <memdraw.h>#include <keyboard.h>#include <cursor.h>#include "screen.h" Memimage *gscreen;extern int screenWidth;extern int screenHeight;char *snarfbuf = nil; unsigned char*screenData(){    int x, y, o;    static unsigned char *ret = NULL;    if (ret == NULL)        ret = malloc(sizeof(unsigned char) * screenWidth * screenHeight * 4);    if (gscreen != NULL && gscreen->data != NULL && gscreen->data->bdata != NULL)        for (y = 0; y < screenHeight; y++)            for (x = 0; x < screenWidth; x++) {                o = (y * screenWidth + x) * 4;                ret[o+0] = 0xFF;                ret[o+1] = gscreen->data->bdata[o+2];                ret[o+2] = gscreen->data->bdata[o+1];                ret[o+3] = gscreen->data->bdata[o+0];            }    return ret;} voidsetterm(int raw){    return;} /** * TODO: android clipboard */char*clipread(void){    return strdup(snarfbuf == nil? "": snarfbuf);} intclipwrite(char *buf){    if (snarfbuf != nil)        free(snarfbuf);    snarfbuf = strdup(buf);    return 0;} voidsetcolor(ulong i, ulong r, ulong g, ulong b){    return;} voidgetcolor(ulong v, ulong *r, ulong *g, ulong *b){    *r = (v>>16)&0xFF;    *g = (v>>8)&0xFF;    *b = v&0xFF;} voidflushmemscreen(Rectangle r){    return;} voidscreeninit(void){    memimageinit();    gscreen = allocmemimage(Rect(0,0,screenWidth,screenHeight), XRGB32);    terminit();    return;} uchar*attachscreen(Rectangle *r, ulong *chan, int *depth, int *width, int *softscreen){    *r = gscreen->r;    *depth = gscreen->depth;    *chan = gscreen->chan;    *width = gscreen->width;    *softscreen = 0;    return gscreen->data->bdata;} voidsetcursor(void){    return;} voidmouseset(Point xy){    return;}