2 * Written by Nick Kovac with minor changes by Claudio Matsuoka
8 static int plane_select[4] = { 0, 0, 0, 0 };
9 static int line_compare = 0;
10 static int hscroll_offset = 0;
11 static uint8_t palette[256 * 3];
13 #define SCREEN_WIDTH 320
14 #define SCREEN_HEIGHT 400
15 #define FRAME_BUFFER_WIDTH 384
16 #define FRAME_BUFFER_HEIGHT 400
18 uint8_t fb[FRAME_BUFFER_WIDTH * FRAME_BUFFER_HEIGHT];
21 void vga_select_bitplanes_02()
29 void vga_select_bitplanes_13()
37 void vga_select_bitplanes_0123()
45 void vga_write32(int offset, int val)
49 // For each selected plane, calculate 4 pixel offsets and write 4 bytes.
50 // offset = 0, 4, 8, etc
52 for (i = 0; i < 4; i++) {
53 if (plane_select[i]) {
54 for (j = 0; j < 4; j++) {
56 uint8_t b = (val >> (j * 8));
59 int fb_offs = i + (offset + j) * 4;
68 void vga_set_line_compare(int y)
73 void vga_set_palette_entry(int index, int r, int g, int b)
81 extern unsigned char *image; // The OpenGL background image texture
83 void vga_show_framebuffer()
87 int nFirstLineIndex = line_compare + 1;
89 // Plot the palettised frame buffer.
90 unsigned int *ptr = fb;
93 memset(image, 0, FRAME_BUFFER_WIDTH * FRAME_BUFFER_HEIGHT * 3);
98 for (y = nFirstLineIndex; y < SCREEN_HEIGHT; y++) {
99 for (x = 0; x < SCREEN_WIDTH; x++) {
100 //ASSERT(x + hscroll_offset < FRAME_BUFFER_WIDTH);
102 int idx = ptr[x + hscroll_offset] * 3;
108 int ofs = (y * 320 + x) * 3;
109 image[ofs++] = r << 2;
110 image[ofs++] = g << 2;
114 ptr += FRAME_BUFFER_WIDTH;
118 void vga_set_hscroll_offset(int offset)
120 hscroll_offset = offset;
123 void vga_upload_palette(uint8_t *pal)
125 memcpy(palette, pal, 256 * 3);