mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[qwaq] Support background and clearing in DrawBuffer
This commit is contained in:
parent
490f1ad4b8
commit
e49ba896aa
2 changed files with 29 additions and 0 deletions
|
@ -18,6 +18,8 @@
|
|||
- blitFromBuffer: (DrawBuffer *) srcBuffer to: (Point) pos from: (Rect) rect;
|
||||
- (Extent) size;
|
||||
|
||||
- (void) bkgd: (int) ch;
|
||||
- (void) clear;
|
||||
- (void) printf: (string) fmt, ...;
|
||||
- (void) vprintf: (string) fmt, @va_list args;
|
||||
- (void) addch: (int) ch;
|
||||
|
@ -33,6 +35,7 @@
|
|||
int *buffer;
|
||||
Extent size;
|
||||
Point cursor;
|
||||
int background;
|
||||
}
|
||||
+ (DrawBuffer *) buffer: (Extent) size;
|
||||
- initWithSize: (Extent) size;
|
||||
|
|
|
@ -80,6 +80,26 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) bkgd: (int) ch
|
||||
{
|
||||
if ((ch & 0xff) < 32) {
|
||||
ch = (ch & ~0xff) | 32;
|
||||
}
|
||||
background = ch;
|
||||
}
|
||||
|
||||
- (void) clear
|
||||
{
|
||||
int ch = background;
|
||||
int *dst = buffer;
|
||||
int *end = buffer + size.width * size.height;
|
||||
|
||||
while (dst < end) {
|
||||
*dst++ = ch;
|
||||
}
|
||||
cursor = {0, 0};
|
||||
}
|
||||
|
||||
- (void) printf: (string) fmt, ...
|
||||
{
|
||||
string str = vsprintf (fmt, @args);
|
||||
|
@ -113,6 +133,12 @@
|
|||
} else if (ch == '\r') {
|
||||
cursor.x = 0;
|
||||
} else {
|
||||
if ((ch & 0xff) < 32) {
|
||||
ch = (ch & ~0xff) | 32;
|
||||
}
|
||||
if (!(ch & ~0xff)) {
|
||||
ch |= background & ~0xff;
|
||||
}
|
||||
buffer[cursor.y * size.width + cursor.x++] = ch;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue