VGA driver wont draw a bitmap

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
stevenup7002
Member
Member
Posts: 60
Joined: Tue Sep 20, 2005 11:00 pm
Location: Ireland
Contact:

VGA driver wont draw a bitmap

Post by stevenup7002 »

Hi, I want my VGA driver to draw a 16 color bitmap to the screen, but all I get is a gray screen with a white blinking cursor. I'm not sure what I'm doing wrong, but I'm pretty sure I'm on the right track. I first made a 16 color bitmap in paint for testing the vga driver, then I exported it to C code in GIMP. It might be just a small problem but Im completely stuck at this:

Code: Select all

/*
 *  The Sendla Operating System
 *  Copyright 2007 Steven O'Brien (Motron Software.) and Brandon F.
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the Free
 *  Software Foundation; either version 2 of the License, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *  for more details.
 * 
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * 
 * Sendla VGA Driver
*/

#include <system.h>

unsigned char *VGA = (unsigned char *)0xA0000L; /* First of all, we put a pointer in video memory, this is how to do it in PMODE */
unsigned char *dbl_buffer; 
unsigned int SCREEN_WIDTH=320;
unsigned int SCREEN_HEIGHT=200;

/* Bitmap Structure */
typedef struct tagBITMAP
{
    unsigned int width;
    unsigned int height;
    unsigned char *data;
} BITMAP;

/* Structure for the position on the screen */
typedef struct tagRECT
{
    long x1;
    long y1;
    long x2;
    long y2;
} RECT;

static const struct vgatest {
  unsigned int 	 width;
  unsigned int 	 height;
  unsigned int 	 bytes_per_pixel; /* 3:RGB, 4:RGBA */ 
  unsigned char	 data[121 * 25 * 3 + 1];
} vgatest = {
  121, 25, 3,
  "\376\376\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\200"
  "\0\200\0\200\200\376\376\376\376\376\376\376\376\376\0\200\200\376\376\376"
  "\376\376\376\376\376\376\376\376\0\376\376\376\0\0\376\0\376\0\376\376\376"
  "\0\200\200\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\200\0\200\200\0"
  "\200\376\376\0\376\376\376\376\376\376\376\376\0\376\376\376\200\0\200\200"
  "\0\200\376\376\0\200\0\200\376\0\0\376\376\376\200\0\200\376\376\376\376"
  "\376\0\0\376\0\376\376\376\277\277\277\0\200\200\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\0\0\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\200"
  "\0\200\376\376\376\376\376\0\376\376\376\0\0\376\376\376\376\376\376\376"
  "\0\0\376\0\376\0\0\200\200\0\200\200\200\0\0\0\376\0\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376"
  "\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\0\200\0\200"
  "\376\376\376\376\376\376\376\376\376\376\376\376\0\200\200\376\376\376\376"
  "\376\376\376\376\0\0\200\200\0\200\200\0\376\0\376\376\376\200\0\200\0\0"
  "\376\200\0\0\376\376\376\0\0\376\376\376\376\376\376\376\0\200\200\277\277"
  "\277\0\376\0\277\277\277\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\0\376\376\376\376\376\0\376"
  "\376\376\0\0\376\200\0\0\376\376\376\376\376\376\277\277\277\376\376\376"
  "\376\0\0\376\376\376\376\376\376\0\0\376\0\200\200\376\376\376\376\376\376"
  "\0\200\200\0\376\0\376\376\376\0\200\200\0\200\200\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376"
  "\376\200\0\200\376\376\376\376\376\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\200\0\200\0\0\0\376\376\376\376\376"
  "\376\200\0\0\376\376\376\0\200\200\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\0\0\376\0\376\0\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376"
  "\376\376\376\376\376\376\0\376\376\376\376\376\0\376\376\376\0\0\0\376\376"
  "\0\376\376\376\376\0\0\200\0\200\376\376\0\376\376\376\376\376\376\0\0\0"
  "\0\200\200\376\376\376\376\376\376\376\0\0\376\376\376\0\0\376\376\376\376"
  "\376\376\376\376\376\376\0\200\200\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\0\0\0\376\376\376\376\0"
  "\0\376\376\376\0\376\376\0\0\376\0\200\200\376\0\376\376\376\376\0\200\200"
  "\376\376\0\0\0\0\376\376\0\376\376\376\376\0\0\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\376\0\376\376\376"
  "\376\376\0\200\200\376\376\0\376\376\376\376\376\376\200\0\200\0\376\376"
  "\0\376\376\376\0\0\376\376\376\376\376\376\376\376\376\277\277\277\376\376"
  "\376\0\200\200\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\376\0\0\0\376"
  "\0\376\0\200\200\0\0\376\200\200\0\200\0\0\376\0\376\200\0\200\376\0\376"
  "\200\0\200\376\376\376\0\0\0\0\200\200\0\376\0\0\200\200\0\376\0\376\0\0"
  "\200\0\0\376\376\376\0\376\0\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\200\0\200\0\376\376\376\376\376\376"
  "\376\376\200\0\200\200\200\0\200\0\200\0\200\200\376\0\376\376\0\376\0\376"
  "\376\0\200\0\376\0\0\0\0\200\0\200\200\376\376\376\376\376\376\0\376\0\376"
  "\376\376\376\376\376\376\376\376\0\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\200\200\0\376\0\376\376\376\376\376\376\376\0\376\376"
  "\376\376\376\0\0\376\0\0\0\200\0\200\376\0\0\277\277\277\0\0\376\376\0\376"
  "\0\200\0\200\200\0\376\0\0\0\0\200\0\0\376\0\0\200\376\376\376\376\376\376"
  "\376\376\376\277\277\277\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\200\200\0\0\0\0\376\376\376\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\0\376\376\376\376\376\376\376\376\376\376\376\376\376\277\277"
  "\277\200\0\200\200\200\0\0\200\200\277\277\277\0\200\0\376\376\376\376\376"
  "\376\0\0\200\376\376\376\376\376\376\0\376\0\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\200"
  "\0\200\376\376\376\376\376\376\0\0\200\376\376\0\200\200\0\0\0\376\376\376"
  "\376\376\376\376\0\200\200\200\0\200\376\376\376\376\376\376\376\376\376"
  "\200\200\0\376\376\376\376\0\0\200\0\0\0\0\200\0\0\376\0\0\200\376\376\376"
  "\200\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376"
  "\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\0\0\0\376\376\376\376\0\376\376\376\376\376\376\0\200\0\200\376\376\0\376"
  "\0\0\0\0\376\200\200\0\376\376\376\376\376\376\376\376\376\200\0\200\200"
  "\0\0\0\0\376\0\200\200\376\376\376\376\376\376\0\0\200\0\0\376\376\376\376"
  "\0\0\376\0\200\200\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376"
  "\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\200\200\0\376\376\376\376\376\376\376\376\376\376\376\376"
  "\200\0\200\376\376\376\376\0\0\200\0\200\0\0\376\376\376\376\376\0\376\0"
  "\0\200\0\376\376\376\376\376\376\376\376\376\376\376\0\376\0\277\277\277"
  "\0\0\200\0\0\376\376\376\376\200\200\200\0\0\200\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376"
  "\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\0\0\200\200\200\376\376"
  "\376\200\0\200\376\376\376\376\376\376\0\0\200\200\0\200\0\200\0\376\376"
  "\376\376\376\376\200\0\0\200\0\0\376\0\376\376\0\0\0\0\200\0\0\376\376\376"
  "\376\376\0\376\0\0\200\0\0\200\0\200\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376"
  "\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\0\376\376\376\376\0\0\200\0\0\200\376\376\376\376\376\376\376"
  "\376\376\376\376\376\200\200\0\0\0\376\376\376\376\0\0\200\376\0\376\0\376"
  "\0\0\0\200\0\200\0\0\0\200\0\376\0\0\0\200\376\376\376\0\0\200\0\376\0\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376"
  "\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\200\200\0\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\0\0\200\376\376\376\376"
  "\376\376\0\376\376\376\376\376\0\200\200\376\376\376\376\0\0\376\376\376"
  "\0\0\200\376\376\376\376\376\376\376\0\0\0\0\200\0\0\200\0\0\200\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0"
  "\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\0\0\376\0\0\376\0\0\376\0\0\376\0\0\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\0\0\376\0\0\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\0\0\200\200\200\0\0\376\376\0\376\376\200\200\200"
  "\376\376\376\376\376\376\376\376\376\376\376\376\0\376\376\0\376\376\376"
  "\376\376\376\0\376\0\200\200\376\376\376\277\277\277\0\0\200\376\376\376"
  "\0\200\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\0\0\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\0\0\376\0\0\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\200\200\0\0\0\0\376\376\376\376\376\376\376\376"
  "\376\376\0\376\376\0\376\200\200\200\376\376\376\376\376\376\376\376\376"
  "\200\200\0\376\376\376\376\0\376\376\376\376\0\0\200\200\200\200\376\0\0"
  "\376\0\0\376\376\376\0\0\200\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\200\200\0\376\376\376\0\200\0\0\376\376\200"
  "\200\0\376\376\376\376\376\376\376\376\376\376\376\376\200\200\200\376\376"
  "\376\376\376\376\376\376\376\376\0\0\376\376\376\376\376\376\376\376\376"
  "\200\200\200\376\376\376\376\376\376\0\200\0\376\376\376\200\200\200\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\200\200\0\376\376\376\200\200\200\376\376\376\376\376"
  "\376\376\376\376\0\0\200\376\0\376\200\200\200\0\0\0\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\0\376\376\0\200\0\376\376\376\376"
  "\376\376\0\200\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\200\200"
  "\0\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\0\0\200\376"
  "\376\376\376\376\376\376\0\376\376\376\376\0\200\0\376\376\376\376\376\376"
  "\0\0\200\200\200\200\376\0\376\200\200\200\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\200\200\200\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\0\376\376\376\376\376"
  "\376\376\376\376\0\376\376\376\376\0\0\200\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\200\200\200\376\376\376\0\376\376\0\0\200\0"
  "\200\0\376\376\376\0\0\200\376\376\376\376\376\376\376\376\376\0\0\200\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376"
  "\376\376\376\376\376",
};

/* Initiates a double buffer */
void init_dbl_buffer(void)
{
    dbl_buffer = (unsigned char *) malloc (SCREEN_WIDTH * SCREEN_HEIGHT);
    if (dbl_buffer == NULL)
    {
	puts("Not enough memory for double buffer.\n");
    }
}

/* If you dont know what this does then you should be watching tv instead */
void update_screen(void)
{
    #ifdef VERTICAL_RETRACE
      while ((inportb(0x3DA) & 0x08));
      while (!(inportb(0x3DA) & 0x08));
    #endif
    memcpy(VGA, dbl_buffer, (unsigned int)(SCREEN_WIDTH * SCREEN_HEIGHT));
}

/* Plots a pixel */
void setpixel (BITMAP *bmp, int x, int y, unsigned char color)
{
    bmp->data[y * bmp->width + x];
}

/* Draws a filled rectangle in a bitmap. */
void drawrect(BITMAP *bmp, unsigned short x, unsigned short y, unsigned short x2, unsigned short y2, unsigned char color)
{
    unsigned short tx, ty;
    for (ty = y; ty < y2; ty++)
	for (tx = x; tx < x2; tx++)
	    setpixel (bmp, tx, ty, color);
}


void draw_bitmap_old(BITMAP *bmp, int x, int y)
{
    int j;
    unsigned int screen_offset = (y << 8) + (y << 6) + x;
    unsigned int bitmap_offset = 0;

    for(j = 0; j < bmp->height; j++)
    {
	memcpy(&dbl_buffer[screen_offset], &bmp->data[bitmap_offset], bmp->width);

	bitmap_offset += bmp->width;
	screen_offset += SCREEN_WIDTH;
    }
}

/* Just a test to make sure it works */
void vga_test() 
{
    unsigned char key; puts("l2");
    do 
    {
        key = 0; 
        if (1) key = getc();

        /* You must clear the double buffer every time to avoid evil messes
            (go ahead and try without this, you will see) */
        memset (dbl_buffer, 0, SCREEN_WIDTH * SCREEN_HEIGHT);


      //drawrect( vgatest.data, 0, 0, vgatest.width, vgatest.height, 0x1 );

      draw_bitmap_old( vgatest.data, 320, 200 ); 


        /* Draws the double buffer */
        update_screen();

    } while (key != 27);	/* Continue Loop until ESC */
}


Thanks in advance,
-Steven
User avatar
hakware
Member
Member
Posts: 66
Joined: Sat Mar 31, 2007 4:57 pm
Location: Xanadu
Contact:

Post by hakware »

I think you need to take it out of text mode. I'm a little cloudy on how this is done, but I think it's probably something like this:

Code: Select all

outportb(0x3ce , 0x06); // Select index 0x06 (misc graphics register) in port 0x3ce (graphics address register)
outportb( 0x3cf, 0x01);  // Set misc graphics register to 0001b 
/* Graphics register bitmap:
   Bit    Meaning 
    0      If 1, graphics mode
    1      0 is even mode, 1 is odd mode
    2-3   00 means bitmap is 0xa0000-0xbffff
            01 means bitmap is 0xa0000-0xaffff
            10 means bitmap is 0xb0000-0xb7fff
            11 means bitmap is 0xb0000-0xbffff
*/
Btw, I'm taking the specs I based the code off of from The FreeVGA Project. I admit, I'm not very familiar with this stuff -- I haven't gotten to coding it myself yet ;-). I hope I helped.

~John

P.S.: You might also need to set the pallette ;-)

(edit: I actually meant "when set to 1, graphics mode" not "text mode")
Last edited by hakware on Sat Apr 07, 2007 2:43 pm, edited 1 time in total.
"It is time to return real programming to users and even beginning users, to whom it has been denied since 1984."
- Theodore Holm Nelson

Image
User avatar
stevenup7002
Member
Member
Posts: 60
Joined: Tue Sep 20, 2005 11:00 pm
Location: Ireland
Contact:

Post by stevenup7002 »

It didnt really work because I can still see the cursor, only this time, it's at the top of the screen.
User avatar
hakware
Member
Member
Posts: 66
Joined: Sat Mar 31, 2007 4:57 pm
Location: Xanadu
Contact:

Post by hakware »

Oh right... x86 is little endian, so instead try 0xa0 (at least, I think that's equivalent to 1000000b ... I'm brainfried atm, sry).
"It is time to return real programming to users and even beginning users, to whom it has been denied since 1984."
- Theodore Holm Nelson

Image
User avatar
stevenup7002
Member
Member
Posts: 60
Joined: Tue Sep 20, 2005 11:00 pm
Location: Ireland
Contact:

Post by stevenup7002 »

That didnt work either, also, on virtual PC (don't flame, it was the nearest thing I had) It says that an internal error has occured about 45 seconds after the gray screen appeared.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Programming a vga in 16-color mode is rather difficult: this is because of the memory model implied:

every pixel is defined by four bits. each of the four bits is located in a different bank, known as "plane". To write one pixel, you have to set/clear bits in 4 different locations - not the easiest thing to do. It will also mean that a single memcpy will never work as you have to write each plane one at a time.

The easiest graphics mode is 320x200, 256 colors. This mode hides the ugly details of the VGA for you so you can access the way you do now.

Like hakware said, you first will need to get into graphics mode. You can't simply change the Graphics/Alphanumeric bit, as there is far more needed to get things to work. (This involves mainly the GC, but several other components need to be adjusted to match.)

Some sample sourcecode for setting modes:
http://dimensionalrift.homelinux.net/co ... vga_io.bas

There are some graphics functions (clearscreen, putpixel, text output) near the end of this file:
http://dimensionalrift.homelinux.net/co ... st_gfx.bas

Regarding the MSVPC error, it probably has something to do with something else than the VGA code. VPC of itself has quite accurate VGA emulation (Actually, i use it as the last test before trying real hardware)

Good luck
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

Indeed, with 16-color mode, you have 4 different planes one for each bit of the color and you draw each plane separately. This is actually the same way you draw on Amiga and so it happens that possibly the best explanation of the whole thing I've seen was in an Amiga FAQ:

http://amiga.nvg.org/amiga/amigafaq/Ami ... html#SEC16

So VGA 16-color mode is what the document calls planar mode, while so called "linear framebuffers" (which 320x200x256 happens to be) are what the document calls "chunky" modes. (The document mentions PCs but it means 256-color mode.. 16-color is indeed Amiga style bitplanar.)
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
User avatar
stevenup7002
Member
Member
Posts: 60
Joined: Tue Sep 20, 2005 11:00 pm
Location: Ireland
Contact:

Post by stevenup7002 »

I'm converting http://dimensionalrift.homelinux.net/co ... vga_io.bas into C now if anyone is interested. Also I think I am going wrong in a few places in it, you'll see what I mean in a few minutes.
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

I actually think that 640x480x16-colors would be a better "safe-mode" than 320x200x256-color for a typical GUI. For color display 16-colors are too little, but if you set the 16-color palette such that it only contains various levels of gray, you can draw decent looking gray-scale images. You could even tint is slightly, if you feel like it.

The advantage over 320x200 then, is that you've got over 4-times pixels to draw your GUI components with, making it much easier to fit stuff on the screen. 16 levels of grayscale are still enough to do stuff like shading and anti-aliasing, so it can look relatively ok. For good looking color-display, you need more than VGA anyway.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
User avatar
stevenup7002
Member
Member
Posts: 60
Joined: Tue Sep 20, 2005 11:00 pm
Location: Ireland
Contact:

Post by stevenup7002 »

Well, here is the basic driver rewritten in C. Enjoy:

Code: Select all

 /*
 *  The Sendla Operating System
 *  Copyright 2007 (Steven O'Brien) Motron Software. Used without permission from public domain work by Marcel Sondaar.
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the Free
 *  Software Foundation; either version 2 of the License, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  wITHOUT ANY wARRANTY; without even the implied warranty of MERCHANTABILITY
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *  for more details.
 * 
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * Sendla OS VGA Driver 
 */

#include <system.h>

/* well this is my second attempt at a VGA driver, lets hope this one will do better */

void write3C0(char index, unsigned char value)
{
     inportb(0x3DA);
     outportb(0x3C0, index);
     outportb(0x3C0, value);
}


void write3C2(unsigned char value)
{
     outportb(0x3C2, value);
}

void write3C4(char index, unsigned char value)
{
    if (index==1)
	{
	 outportw(0x3C4,0x0100);
         outportb(0x3C4,0x0300);
         outportb(0x3C4+1,0x0300);
        }
    else
	{
	 outportb(0x3C4,index);
	 outportb(0x3C4+1,value);
  	}
}

void write3C6(unsigned char value)
{
    outportb(0x3C6, value);
}

void write3CE(char index, unsigned char value)
{
    outportb(0x3CE,index);
    outportb(0x3CE/*+1*/,value);
}

void write3D4(char index, unsigned char value)
{
    outportb(0x3D4,index);
    outportb(0x3D4+1,value);
}

unsigned char Read3C0(unsigned char index)
{
    inportb(0x3DA);
    outportb(0x3C0, index);
    return inportb(0xC0+1);
}

unsigned char Read3C2(void)
{
    return inportb(0x3CC);
}

unsigned char Read3C4(char index)
{
    outportb(0x3C4, index);
    return inportb(0x3C4+1);
}

unsigned char Read3C6(void)
{
    return inportb(0x3C6);
}


unsigned char Read3CE(char index)
{
    outportb(0x3CE, index);
    return inportb(0x3CE/*+1*/);
}

unsigned char Read3D4(char index)
{
    outportb(0x3D4, index);
    return inportb(0x3D4+1);
}

void VGAunlockCRTC(void)
{
   char temp[1];
   temp[0]=Read3D4(0x11); 
   temp[1]=0x7F;
   write3D4(0x11,temp);
}

void VGAEnableDisplay(void)
{
   inportb (0x3DA);
   outportb (0x3C0, 0x20);
}

void VGASet320x200Mode()
{
    VGASet320x240Mode();
    write3C2(0x63);
    write3D4(0, 0x5f);
    write3D4(1, 0x4f);
    write3D4(2, 0x50);
    write3D4(3, 0x82);
    write3D4(4, 0x54);
    write3D4(5, 0x80);
    write3D4(6, 0xbf);
    write3D4(7, 0x1f);
    write3D4(8, 0x00);
    write3D4(9, 0x41);
    write3D4(0x10, 0x9c);
    write3D4(0x11, 0x0e);
    write3D4(0x12, 0x8f);
    write3D4(0x13, 0x28);
    write3D4(0x14, 0x40);
    write3D4(0x15, 0x96);
    write3D4(0x16, 0xb9);
    write3D4(0x17, 0xa3);

    write3C4(1, 0x01);
    write3C4(2, 0x0f);
    write3C4(4, 0x0e);

    write3CE(0, 0x00);
    write3CE(1, 0x00);
    write3CE(2, 0x00);
    write3CE(3, 0x00);
    write3CE(4, 0x00);
    write3CE(5, 0x40);
    write3CE(6, 0x05);
    write3CE(7, 0x0F);
    write3CE(8, 0xFF);

    write3C0(0x10, 0x41);
    write3C0(0x11, 0);
    write3C0(0x12, 0x0f);
    write3C0(0x13, 0);
    write3C0(0x14, 0);
}

void VGASet320x240Mode()
{
    write3C2(0xe3);
    write3D4(0, 0x5f);
    write3D4(1, 0x4f);
    write3D4(2, 0x50);
    write3D4(3, 0x82);
    write3D4(4, 0x54);
    write3D4(5, 0x80);
    write3D4(6, 0x0d);
    write3D4(7, 0x3e);
    write3D4(8, 0x00);
    write3D4(9, 0x41);
    write3D4(0x10, 0xea);
    write3D4(0x11, 0x2c);
    write3D4(0x12, 0xdf);
    write3D4(0x13, 0x28);
    write3D4(0x14, 0x40);
    write3D4(0x15, 0xe7);
    write3D4(0x16, 0x03);
    write3D4(0x17, 0xa3);
    write3C4(1, 0x01);
    write3C4(4, 0x0e);
    write3CE(5, 0x40);
    write3CE(6, 0x05);
    write3C0(0x10, 0x41);
    write3C0(0x13, 0);
}

void VGASet400x300Mode()
{
    write3C2(0xeb);
    write3D4(0, 0x89);
    write3D4(1, 0x63);
    write3D4(2, 0x64);
    write3D4(3, 0x8c);
    write3D4(4, 0x6f);
    write3D4(5, 0x09);
    write3D4(6, 0x70);
    write3D4(7, 0xf0);
    write3D4(8, 0x00);
    write3D4(9, 0xe0);
    write3D4(0x10, 0x58);
    write3D4(0x11, 0x0c);
    write3D4(0x12, 0x57);
    write3D4(0x13, 0x32);
    write3D4(0x14, 0x00);
    write3D4(0x15, 0x58);
    write3D4(0x16, 0x70);
    write3D4(0x17, 0xe3);
    write3C4(1, 0x01);
    write3C4(4, 0x06);
    write3CE(5, 0x40);
    write3CE(6, 0x05);
    write3C0(0x10, 0x41);
    write3C0(0x13, 0);
}

void VGASet640x480x16Mode()
{
    write3C2(0xE3);

    write3C4(1, 0x01);
    write3C4(2, 0x08);
    write3C4(4, 0x06);

    write3D4(0, 0x5f);
    write3D4(1, 0x4f);
    write3D4(2, 0x50);
    write3D4(3, 0x82);
    write3D4(4, 0x54);
    write3D4(5, 0x80);
    write3D4(6, 0x0b);
    write3D4(7, 0x3e);
    write3D4(8, 0x00);
    write3D4(9, 0x40);
    write3D4(0x10, 0xea);
    write3D4(0x11, 0x0c);
    write3D4(0x12, 0xdf);
    write3D4(0x13, 0x28);
    write3D4(0x14, 0x00);
    write3D4(0x15, 0xe7);
    write3D4(0x16, 0x04);
    write3D4(0x17, 0xe3);

    write3CE(0, 0x00);
    write3CE(1, 0x00);
    write3CE(2, 0x00);
    write3CE(3, 0x00);
    write3CE(4, 0x03);
    write3CE(5, 0x00);
    write3CE(6, 0x05);
    write3CE(7, 0x0F);
    write3CE(8, 0xFF);

    write3C0(0x10, 0x01);
    write3C0(0x11, 0);
    write3C0(0x12, 0x0f);
    write3C0(0x13, 0);
    write3C0(0x14, 0);
}

void VGASetTextMode()
{

unsigned char g_80x25_text[] =
{
/* MISC */
	0x67,
/* SEQ */
	0x03, 0x00, 0x03, 0x00, 0x02,
/* CRTC */
	0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F,
	0x00, 0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x50,
	0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3,
	0xFF,
/* GC */
	0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00,
	0xFF,
/* AC */
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
	0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
	0x0C, 0x00, 0x0F, 0x08, 0x00
};

    write3C2(0x67);
    write3D4(0, 0x5f);
    write3D4(1, 0x4f);
    write3D4(2, 0x50);
    write3D4(3, 0x82);
    write3D4(4, 0x55);
    write3D4(5, 0x81);
    write3D4(6, 0xbf);
    write3D4(7, 0x1f);
    write3D4(8, 0x00);
    write3D4(9, 0x4f);

    write3D4(0x10, 0x9c);
    write3D4(0x11, 0x0e);
    write3D4(0x12, 0x8f);
    write3D4(0x13, 0x28);
    write3D4(0x14, 0x1f);
    write3D4(0x15, 0x96);
    write3D4(0x16, 0xb9);
    write3D4(0x17, 0xa3);

    write3C4(1, 0x00);
    write3C4(3, 0x00);
    write3C4(4, 0x00);
    write3CE(5, 0x10);
    write3CE(6, 0x0e);

    write3C0(0x10, 0x0c);
    write3C0(0x13, 0x08);
}


void VGASetModeX(void)
{
    write3D4(0x14, Read3D4(0x14) && 0xBF);
    write3D4(0x17, Read3D4(0x17) || 0x40);
    write3C4(4, Read3C4(4) && 0xF7);
}
Post Reply