Commit dbbcf3da authored by deuce's avatar deuce
Browse files

Implement clreol() and clrscr() to avoid extra allocations in ciolib.

parent 1a4c6c79
......@@ -243,7 +243,7 @@ int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy)
pthread_mutex_lock(&vstatlock);
for(cy=(direction==-1?(height-1):0); cy<height && cy>=0; cy+=direction) {
damaged[toy+cy]=1;
damaged[toy+cy-1]=1;
sourcepos=((y-1)+cy)*cio_textinfo.screenwidth+(x-1);
memmove(&(vstat.vmem[sourcepos+destoffset]), &(vstat.vmem[sourcepos]), sizeof(vstat.vmem[0])*width);
}
......@@ -251,6 +251,33 @@ int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy)
return(1);
}
void bitmap_clreol(void)
{
int pos,x;
WORD fill=(cio_textinfo.attribute<<8)|' ';
pos=(cio_textinfo.cury+cio_textinfo.wintop-2)*cio_textinfo.screenwidth;
pthread_mutex_lock(&vstatlock);
damaged[cio_textinfo.cury-1]=1;
for(x=cio_textinfo.curx+cio_textinfo.winleft-2; x<cio_textinfo.winright; x++)
vstat.vmem[pos+x]=fill;
pthread_mutex_unlock(&vstatlock);
}
void bitmap_clrscr(void)
{
int x,y;
WORD fill=(cio_textinfo.attribute<<8)|' ';
pthread_mutex_lock(&vstatlock);
for(y=cio_textinfo.wintop-1; y<cio_textinfo.winbottom; y++) {
damaged[y]=1;
for(x=cio_textinfo.winleft-1; x<cio_textinfo.winright; x++)
vstat.vmem[y*cio_textinfo.screenwidth+x]=fill;
}
pthread_mutex_unlock(&vstatlock);
}
int bitmap_puttext(int sx, int sy, int ex, int ey, void *fill)
{
int x,y;
......
......@@ -22,5 +22,7 @@ int bitmap_init_mode(int mode, int *width, int *height);
int bitmap_init(void (*drawrect_cb) (int xpos, int ypos, int width, int height, unsigned char *data)
,void (*flush) (void));
int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy);
void bitmap_clreol(void);
void bitmap_clrscr(void);
#endif
......@@ -129,6 +129,8 @@ int try_sdl_init(int mode)
cio_api.getfont=bitmap_getfont;
cio_api.loadfont=bitmap_loadfont;
cio_api.movetext=bitmap_movetext;
cio_api.clreol=bitmap_clreol;
cio_api.clrscr=bitmap_clrscr;
cio_api.kbhit=sdl_kbhit;
cio_api.getch=sdl_getch;
......@@ -168,6 +170,8 @@ int try_x_init(int mode)
cio_api.loadfont=bitmap_loadfont;
cio_api.beep=x_beep;
cio_api.movetext=bitmap_movetext;
cio_api.clreol=bitmap_clreol;
cio_api.clrscr=bitmap_clrscr;
cio_api.kbhit=x_kbhit;
cio_api.getch=x_getch;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment