#include "video.h"
#include "asmops.h"
#include "keyb.h"
+#include "contty.h"
static uint16_t *framebuf;
int vbetest(void)
{
- int i, nmodes;
+ int i, j, nmodes;
struct video_mode vi;
+ uint16_t *fbptr;
nmodes = video_mode_count();
printf("%d video modes found:\n", nmodes);
if(video_mode_info(i, &vi) == -1) {
continue;
}
- printf(" %04x: %dx%d %d bpp (%d%d%d)\n", vi.mode, vi.width, vi.height, vi.bpp,
- vi.rbits, vi.gbits, vi.bbits);
+ printf(" %04x: %dx%d %d bpp", vi.mode, vi.width, vi.height, vi.bpp);
+ if(vi.bpp > 8) {
+ printf(" (%d%d%d)\n", vi.rbits, vi.gbits, vi.bbits);
+ } else {
+ putchar('\n');
+ }
}
if(!(framebuf = set_video_mode(find_video_mode(640, 480, 16)))) {
return -1;
}
+ get_color_bits(&vi.rbits, &vi.gbits, &vi.bbits);
+ get_color_shift(&vi.rshift, &vi.gshift, &vi.bshift);
+ get_color_mask(&vi.rmask, &vi.gmask, &vi.bmask);
+
+ fbptr = framebuf;
+ for(i=0; i<480; i++) {
+ for(j=0; j<640; j++) {
+ int xor = i^j;
+ uint16_t r = xor & 0xff;
+ uint16_t g = (xor << 1) & 0xff;
+ uint16_t b = (xor << 2) & 0xff;
+
+ r >>= 8 - vi.rbits;
+ g >>= 8 - vi.gbits;
+ b >>= 8 - vi.bbits;
- memset(framebuf, 0xff, 640 * 240 * 2);
+ *fbptr++ = ((r << vi.rshift) & vi.rmask) | ((g << vi.gshift) & vi.gmask) |
+ ((b << vi.bshift) & vi.bmask);
+ }
+ }
+ while(kb_getkey() != -1);
while(kb_getkey() == -1) {
halt_cpu();
}
set_vga_mode(3);
+ con_clear();
return 0;
}
struct vbe_info *info;
struct int86regs regs;
+ printf("vbe_get_info... ");
+
info = (struct vbe_info*)low_mem_buffer;
memcpy(info->sig, "VBE2", 4);
memset(®s, 0, sizeof regs);
- regs.es = (uint32_t)low_mem_buffer >> 4;
+ regs.es = (uint32_t)info >> 4;
regs.eax = 0x4f00;
int86(0x10, ®s);
+ printf("status: %d\n", (regs.eax >> 8) & 0xff);
+
if((regs.eax & 0xffff) != 0x4f) {
return 0;
}
struct vbe_mode_info *mi;
struct int86regs regs;
- mi = (struct vbe_mode_info*)low_mem_buffer;
+ mi = (struct vbe_mode_info*)(low_mem_buffer + 512);
memset(®s, 0, sizeof regs);
- regs.es = (uint32_t)low_mem_buffer >> 4;
+ regs.es = (uint32_t)mi >> 4;
regs.eax = 0x4f01;
regs.ecx = mode;
int86(0x10, ®s);
void *set_video_mode(int mode)
{
if(init_once() == -1) return 0;
- if(mode < 0 || mode >= mode_count) return 0;
+ if(mode < 0) return 0;
if(!(mode_info = vbe_get_mode_info(mode))) {
return 0;
vid->rbits = inf->rmask_size;
vid->gbits = inf->gmask_size;
vid->bbits = inf->bmask_size;
+ vid->rshift = inf->rpos;
+ vid->gshift = inf->gpos;
+ vid->bshift = inf->bpos;
vid->rmask = color_mask(inf->rmask_size, inf->rpos);
vid->gmask = color_mask(inf->gmask_size, inf->gpos);
vid->bmask = color_mask(inf->bmask_size, inf->bpos);
int width, height;
int bpp;
int rbits, gbits, bbits;
+ int rshift, gshift, bshift;
unsigned int rmask, gmask, bmask;
};
int get_color_bits(int *rbits, int *gbits, int *bbits);
int get_color_mask(unsigned int *rmask, unsigned int *gmask, unsigned int *bmask);
+int get_color_shift(int *rshift, int *gshift, int *bshift);
/* defined in video_asm.s */
void wait_vsync(void);