static void blitfb_banked(void *fb, int pitch)
{
- int sz, offs, pending;
+ int sz, offs, pending, winsz;
unsigned char *pptr = fb;
+ winsz = cur_mi->win_size << 10;
+
/* assume initial window offset at 0 */
offs = 0;
pending = cur_pgsize;
while(pending > 0) {
- sz = pending > 65536 ? 65536 : pending;
+ sz = pending > winsz ? winsz : pending;
memcpy((void*)0xa0000, pptr, sz);
pptr += sz;
pending -= sz;
#include "vidsys.h"
void test8bpp(void);
+void testrgb(void);
struct vid_modeinfo *vm;
-void *vmem;
+void *vmem, *framebuf;
+int doublebuf;
static const char *usage_fmt = "Usage %s: [options]\n"
"Options: \n"
" -s <XxY>: video resolution\n"
- " -b <bpp>: color depth\n";
+ " -b <bpp>: color depth\n"
+ " -d: double buffer\n";
int main(int argc, char **argv)
{
fprintf(stderr, "invalid color depth: %s\n", argv[i]);
return 1;
}
+ break;
+
+ case 'd':
+ doublebuf = 1;
+ break;
case 'h':
printf(usage_fmt, argv[0]);
fprintf(stderr, "failed to find video mode: %dx%d %dbpp\n", xres, yres, bpp);
return 1;
}
+ vm = vid_modeinfo(mode);
+
+ if(!(framebuf = malloc(vm->pitch * vm->width))) {
+ fprintf(stderr, "failed to allocate main memory framebuffer\n");
+ return 1;
+ }
+
if(!(vmem = vid_setmode(mode))) {
fprintf(stderr, "failed to set video mode %04x\n", mode);
return 1;
}
- vm = vid_modeinfo(mode);
- switch(vm->bpp) {
- case 8:
+ if(vm->bpp == 8) {
test8bpp();
- break;
-
- default:
- break;
+ } else {
+ testrgb();
}
for(;;) {
}
vid_setpal(0, 256, cmap);
- if(vid_islinear()) {
- winsz = INT_MAX;
+ if(doublebuf) {
+ fb = framebuf;
+ for(i=0; i<vm->height; i++) {
+ for(j=0; j<vm->width; j++) {
+ *fb++ = i ^ j;
+ }
+ }
+ vid_blitfb(framebuf, 0);
} else {
- winsz = 65536;
- winpos = 0;
- vid_setwin(0, 0);
+ if(vid_islinear()) {
+ winsz = INT_MAX;
+ } else {
+ winsz = vm->win_size << 10;
+ winpos = 0;
+ vid_setwin(0, 0);
+ }
+ winleft = winsz;
+ fb = vmem;
+
+ vid_vsync();
+
+ for(i=0; i<vm->height; i++) {
+ for(j=0; j<vm->width; j++) {
+ if(winleft-- <= 0) {
+ winpos += vm->win_step;
+ vid_setwin(0, winpos);
+ winleft = winsz;
+ fb = vmem;
+ }
+ *fb++ = i ^ j;
+ }
+ }
}
- winleft = winsz;
- fb = vmem;
+}
- vid_vsync();
+void testrgb(void)
+{
+ int i, j, r, g, b;
+ unsigned char *fb24;
+ uint16_t *fb16;
+ uint32_t *fb32;
+ uint32_t pcol;
+ int winsz, winleft, winpos;
+
+ if(!doublebuf) {
+ if(vid_islinear()) {
+ winsz = INT_MAX;
+ } else {
+ winsz = vm->win_size << 10;
+ winpos = 0;
+ vid_setwin(0, 0);
+ }
+ winleft = winsz;
+ fb24 = vmem;
+ fb32 = vmem;
+ fb16 = vmem;
+
+ vid_vsync();
+ } else {
+ fb24 = framebuf;
+ fb32 = framebuf;
+ fb16 = framebuf;
+ }
for(i=0; i<vm->height; i++) {
for(j=0; j<vm->width; j++) {
- if(winleft-- <= 0) {
- winpos += vm->win_step;
- vid_setwin(0, winpos);
- winleft = winsz;
- fb = vmem;
+ if(!doublebuf) {
+ if(winleft <= 0) {
+ winpos += vm->win_step;
+ vid_setwin(0, winpos);
+ winleft = winsz;
+ fb24 = vmem;
+ fb16 = vmem;
+ fb32 = vmem;
+ }
+ winleft -= (vm->bpp + 7) >> 3;
+ }
+ r = (i ^ j) >> 1;
+ g = i ^ j;
+ b = (i ^ j) << 1;
+ vm->ops.pack(&pcol, r, g, b);
+
+ switch(vm->bpp) {
+ case 15:
+ case 16:
+ *fb16++ = pcol;
+ break;
+
+ case 24:
+ fb24[0] = r;
+ fb24[1] = g;
+ fb24[2] = b;
+ fb24 += 3;
+ break;
+
+ case 32:
+ *fb32++ = pcol;
+ break;
}
- *fb++ = i ^ j;
}
}
+
+ if(doublebuf) {
+ vid_vsync();
+ vid_blitfb(framebuf, 0);
+ }
}
cur_mode->ops.getpal(idx, count, col);
}
-void vid_blitfb(void *fb, int vsync)
+void vid_blitfb(void *fb, int pitch)
{
- cur_mode->ops.blitfb(fb, vsync);
+ if(pitch <= 0) {
+ pitch = cur_mode->pitch;
+ }
+ cur_mode->ops.blitfb(fb, pitch);
}
void vid_setpal(int idx, int count, const struct vid_color *col);
void vid_getpal(int idx, int count, struct vid_color *col);
-void vid_blitfb(void *fb, int vsync);
+void vid_blitfb(void *fb, int pitch);
#endif /* VIDSYS_VIDEO_H_ */