#include <conio.h>
#include <stdlib.h>
#define CHARW 8
#define CHARH 8

unsigned char *video_memory = (unsigned char *) 0xA0000000L;
unsigned char *rom_font = (unsigned char *)0xF000FA6EL;
unsigned char color = 14;

void init_mode13h()
{
 asm {
  mov ax, 0x13
  int 0x10
 }
}

void put_pixel(int x, int y, unsigned char color)
{
 video_memory[y * 320 + x] = color;
}

void init_textmode()
{
 asm {
  mov ax, 0x3
  int 0x10
 }
}

void drawchar(int x, int y, char c)
{
 char *work_byte;
 unsigned char work_bit = 0x80;
 work_byte = rom_font +(c << 3);
 for (int iy = 0; iy < CHARH; iy++)
 {
  work_bit = 0x80;
  for (int ix = 0; ix < CHARW; ix++)
  {
   if ((*work_byte & work_bit))	put_pixel(x +ix, y +iy, color);
   work_bit >>= 1;
  }
  work_byte++;
 }
}

void writestring(int x, int y, char *string)
{
 for (int index = 0; string[index] != 0; index++)
  drawchar(x +(index << 3), y, string[index]);
}

void writestring(int x, int y, int number)
{
 char string[6];
 itoa(number, string, 10);
 for (int index = 0; string[index] != 0; index++)
  drawchar(x +(index << 3), y, string[index]);
}

void main()
{
 init_mode13h();
 writestring(120, 96, "Hello World!");
 writestring(120, 105, 2000);
 getch();
 init_textmode();
}