Skip to content
Snippets Groups Projects
Commit dbbcf3da authored by deuce's avatar deuce
Browse files

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

parent 1a4c6c79
No related branches found
No related tags found
No related merge requests found
...@@ -243,7 +243,7 @@ int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy) ...@@ -243,7 +243,7 @@ int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy)
pthread_mutex_lock(&vstatlock); pthread_mutex_lock(&vstatlock);
for(cy=(direction==-1?(height-1):0); cy<height && cy>=0; cy+=direction) { 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); sourcepos=((y-1)+cy)*cio_textinfo.screenwidth+(x-1);
memmove(&(vstat.vmem[sourcepos+destoffset]), &(vstat.vmem[sourcepos]), sizeof(vstat.vmem[0])*width); 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) ...@@ -251,6 +251,33 @@ int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy)
return(1); 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 bitmap_puttext(int sx, int sy, int ex, int ey, void *fill)
{ {
int x,y; int x,y;
......
...@@ -22,5 +22,7 @@ int bitmap_init_mode(int mode, int *width, int *height); ...@@ -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) int bitmap_init(void (*drawrect_cb) (int xpos, int ypos, int width, int height, unsigned char *data)
,void (*flush) (void)); ,void (*flush) (void));
int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy); int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy);
void bitmap_clreol(void);
void bitmap_clrscr(void);
#endif #endif
...@@ -129,6 +129,8 @@ int try_sdl_init(int mode) ...@@ -129,6 +129,8 @@ int try_sdl_init(int mode)
cio_api.getfont=bitmap_getfont; cio_api.getfont=bitmap_getfont;
cio_api.loadfont=bitmap_loadfont; cio_api.loadfont=bitmap_loadfont;
cio_api.movetext=bitmap_movetext; cio_api.movetext=bitmap_movetext;
cio_api.clreol=bitmap_clreol;
cio_api.clrscr=bitmap_clrscr;
cio_api.kbhit=sdl_kbhit; cio_api.kbhit=sdl_kbhit;
cio_api.getch=sdl_getch; cio_api.getch=sdl_getch;
...@@ -168,6 +170,8 @@ int try_x_init(int mode) ...@@ -168,6 +170,8 @@ int try_x_init(int mode)
cio_api.loadfont=bitmap_loadfont; cio_api.loadfont=bitmap_loadfont;
cio_api.beep=x_beep; cio_api.beep=x_beep;
cio_api.movetext=bitmap_movetext; cio_api.movetext=bitmap_movetext;
cio_api.clreol=bitmap_clreol;
cio_api.clrscr=bitmap_clrscr;
cio_api.kbhit=x_kbhit; cio_api.kbhit=x_kbhit;
cio_api.getch=x_getch; cio_api.getch=x_getch;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment