   Create First Game
  Helloo. I'm newbie need some advice from all you guys. This my problem found...1. I want to build new game using Turbo C. But I confuse when i use interrupt 10 (video mode). It's say illegal information. How can it be?Then when I place one pixel, the screen won't write one pixel but it show like error screen (top screen has been a lot of pixel).2. I've build game too at VB use VBOGL.tlb. The things make me mad is i must include that file (VBOGL.tlb) at my folder. Can I be efficiently to build that?3. What things must I use to develope games at TURBO C? It's core code I know. But it's amazing thing if i can build some game with minimum size.Thanx forever...   
  you will need to take a look at the interrupt table if you havent done so.Interrupt table (around: Int 10/AX=4F05h)It's been a loOong time since ive done this stuff. I could check out some old pascal files on.. floppies. Wonder if my floppy drive still works lol, havent used it for ages.   ;  Isn't Turbo C really old? I mean, the first hit on google for it is Antique Software which dates version 2.0.1 at 1989. Are you *sure* that you want to develop with something so out dated?   ;  most likely you would want to usemov ax,13h  int 10hto setup the graphics mode.sample C++/x86asm code here for both graphics initialization, v-sync, and putpixelvoid init(){ asm mov ax,13h asm int 10h} // switches to 320x200 , 256 colorsvoid close(){asm mov ax,3asm int 10h} // switches back to the default textmode.void waitRetrace(){asm mov dx,3dahwait1:asm in al,dxasm test al,08hasm jnz wait1wait2:asm in al,dxasm test al,08hasm jz wait2} //Vertical synchronizationvoid putpixel(int x,int y,char color){asm mov ax,yasm mov bx,axasm shl ax,8asm shl bx,6asm add bx,axasm add bx,xasm mov ax,0a000hasm mov es,axasm mov al,colorasm mov es:[bx],al};Quote:Isn't Turbo C really old? I mean, the first hit on google for it is Antique Software which dates version 2.0.1 at 1989. Are you *sure* that you want to develop with something so out dated?Presumably he wants an old DOS compiler since he's trying to write DOS programs that muck about with interrupts and whatnot for direct video access (a modern Windows compiler like Visual Studio will not work). That said, DJGPP is a DOS compiler (I think) that is much more up-to-date.   ;  Hi NIQMK,Starting with DOS programming always seems to be the first thing someone wants to learn.  I know, I started there myself.  Only problem is, today's os's don't really support dos calls anymore.  Especially if you are working in windows xp or any of the server windows's, the OS can get real picky about the interrupt handling.  And worse, crash everytime you run your program.Either way, I would like to reccommend to you that you get yourself a nice compiler like devc++ or any other commercial one.  And then start with a Graphics API like Opengl or Directx, depending if you want to code only for windows, or for linux/other os's aswell.My point being, Dos is outdated...but if you are doing it just for fun/interrest, please continue... there's a whole other world in that code! ;)Have phun!Snows   ;  Are u looking for this ?;  Thanx for reply. But seems I confused once again.Well, I know that DOS games is old. I've read some article that say DOS IS DEATH. But how the compiler build some directx, opengl without perform with dos (just like a compiler). And the beginning area 3D is from DOS (as I wasn't wrong).And gan, I've read at brackeen.com (when i try to compile their code. It's said illegal). I don't know what supposed i do. Try to figure out why?It's there any kind for a newbie like me to build some game at DOS with out use graphics library (with assembly ofcourse) likeunion REGS regs;main(){ regs.h.ah=...; regs.h.al=...; int86(0x10, &regs, &regs;}It's there any kind core code to me to learn for build game?   ;Quote:(when i try to compile their code. It's said illegal). I don't know what supposed i do.  illegal ? Last time I use it with Borland ver 4.5 still OK. So, which part of code/IDE showing illegal message?Quote: My point being, Dos is outdated...but if you are doing it just for fun/interrest, please continue...I agree. Since then I never play with it again. I'd rather use OpenGL;  Here is a complete basic mode 13h graphics class for Turbo C++.  I've tested the heck out of it, and I believe it is robust.  Turbo, because it is DOS based, still allows some interrupts and such to be used without crashing the whole machine. The problem is that in a Windows based world you won't know which interrupts you can still play with without a lot of experimentation.  The source below won't compile because of class inheritance, but it should give you everything you need to get something of your own up and running.mode13.cpp#include "\doscla~1\mode13h\mode13.h"#include <alloc.h>#include <conio.h>#include <fstream.h>#include <stdlib.h>#include <string.h>#include <stdio.h>#include <dos.h>#define uchar unsigned char#define uint  unsignedunsigned char far *mode13hClass::buffer = NULL;unsigned mode13hClass::numberOfInstances = 0;unsigned mode13hClass::ready = 0;colorRegisterType mode13hClass::savedPalette[256];int mode13hClass::TOP_EXTENT;int mode13hClass::BOTTOM_EXTENT;int mode13hClass::LEFT_EXTENT;int mode13hClass::RIGHT_EXTENT;int mode13hClass::cameraX;int mode13hClass::cameraY;void mode13hClass::line(uint X0, uint Y0, uint X1, uint Y1, uchar COLOR){int x_inc, y_inc, error=0, dx=X1-X0, dy=Y1-Y0, index=0;if(dx >= 0){  x_inc = 1;}else{  x_inc = -1;  dx = -dx;}if(dy >= 0){  y_inc = 320;}else{  y_inc = -320;  dy = -dy;}unsigned char far *location = buffer + (Y0<<6) + (Y0<<8) + X0;if(dx>dy){  do  {  *location = COLOR;  location += x_inc;  error += dy;  if(error > dx)  {    error -= dx;    location += y_inc;  }  }  while(++index<=dx);}else{  do  {  *location = COLOR;  location += y_inc;  error += dx;  if(error > 0)  {    error -= dy;    location += x_inc;  }  }  while(++index<=dy);}}mode13hClass::mode13hClass(){if(++numberOfInstances == 1){  buffer = (unsigned char far *)farmalloc(64000);  if(buffer ==NULL)  {  clrscr();  cout << "BUFFER ERROR!";  exit(0);  }  _fmemset(buffer, 0, 64000);  addHandlerToKernel(displayBuffer, 1);}TOP_EXTENT = 0;LEFT_EXTENT = 0;RIGHT_EXTENT = 320;BOTTOM_EXTENT = 200;}mode13hClass::~mode13hClass(){if(--numberOfInstances == 0){  farfree(buffer);  removeHandlerFromKernel(displayBuffer);}}void mode13hClass::setVideoMode(unsigned MODE){asm {   mov ax, MODEint 10h }}void mode13hClass::setScreenToMode13h(){asm {   mov ax, 0x13int 10h }}void mode13hClass::setScreenToTextMode(){asm {   mov ax, 0x03int 10h }}void mode13hClass::setPixel(unsigned X, unsigned Y, uchar COLOR){*(buffer + X + (Y<<6) + (Y<<8)) = COLOR;}uchar mode13hClass::getPixel(unsigned X, unsigned Y){return *(buffer + X + (Y<<6) + (Y<<8));}void mode13hClass::clearScreen(uchar COLOR){_fmemset(buffer, COLOR, 64000);}uchar charROM[1028] = {0, 0, 0, 0, 0, 0, 0, 0,126, 129, 165, 129, 189, 153, 129, 126,126, 255, 219, 255, 195, 231, 255, 126,68, 238, 254, 254, 124, 56, 16, 0,16, 56, 124, 254, 124, 56, 16, 0,24, 60, 219, 255, 219, 24, 60, 0,24, 60, 126, 255, 126, 24, 60, 0,0, 0, 60, 60, 60, 60, 0, 0,255, 255, 195, 195, 195, 195, 255, 255,0, 126, 66, 66, 66, 66, 126, 0,255, 129, 189, 189, 189, 189, 129, 255,15, 7, 7, 125, 204, 204, 204, 120,120, 204, 204, 204, 120, 48, 252, 48,31, 51, 63, 48, 48, 112, 240, 224,63, 99, 127, 99, 99, 103, 230, 192,219, 219, 60, 231, 231, 60, 219, 219,192, 240, 248, 254, 248, 240, 192, 0,6, 30, 62, 254, 62, 30, 6, 0,48, 120, 252, 48, 48, 252, 120, 48,108, 108, 108, 108, 108, 0, 108, 0,127, 219, 219, 219, 123, 27, 27, 0,60, 96, 60, 102, 102, 60, 6, 60,0, 0, 0, 0, 254, 254, 254, 0,24, 60, 126, 24, 126, 60, 24, 126,48, 120, 252, 48, 48, 48, 48, 0,48, 48, 48, 48, 252, 120, 48, 0,0, 8, 12, 254, 12, 8, 0, 0,0, 32, 96, 254, 96, 32, 0, 0,0, 0, 192, 192, 254, 0, 0, 0,0, 36, 66, 255, 66, 36, 0, 0,0, 16, 56, 124, 254, 254, 0, 0,0, 254, 254, 124, 56, 16, 0, 0,0, 0, 0, 0, 0, 0, 0, 0,24, 24, 24, 24, 24, 0, 24, 0,204, 204, 204, 0, 0, 0, 0, 0,54, 108, 254, 108, 254, 108, 216, 0,24, 126, 192, 124, 6, 252, 48, 0,194, 198, 12, 24, 48, 102, 198, 0,56, 108, 56, 112, 222, 204, 118, 0,48, 48, 96, 0, 0, 0, 0, 0,12, 24, 48, 48, 48, 24, 12, 0,48, 24, 12, 12, 12, 24, 48, 0,0, 108, 56, 254, 56, 108, 0, 0,0, 24, 24, 126, 24, 24, 0, 0,0, 0, 0, 0, 0, 24, 24, 48,0, 0, 0, 126, 0, 0, 0, 0,0, 0, 0, 0, 0, 24, 24, 0,2, 6, 12, 24, 48, 96, 192, 0,124, 206, 222, 246, 230, 198, 124, 0,24, 56, 24, 24, 24, 24, 126, 0,124, 198, 6, 28, 112, 198, 254, 0,124, 198, 6, 28, 6, 198, 124, 0,28, 60, 108, 204, 254, 12, 12, 0,254, 192, 252, 6, 6, 198, 124, 0,60, 96, 192, 252, 198, 198, 124, 0,254, 198, 12, 24, 48, 48, 48, 0,124, 198, 198, 124, 198, 198, 124, 0,124, 198, 198, 126, 6, 12, 120, 0,0, 24, 24, 0, 0, 24, 24, 0,0, 24, 24, 0, 0, 24, 24, 48,12, 24, 48, 96, 48, 24, 12, 0,0, 0, 126, 0, 0, 126, 0, 0,48, 24, 12, 6, 12, 24, 48, 0,60, 102, 6, 12, 24, 0, 24, 0,124, 198, 222, 222, 222, 192, 124, 0,56, 108, 198, 198, 254, 198, 198, 0,252, 110, 102, 124, 102, 110, 252, 0,62, 98, 192, 192, 192, 98, 62, 0,248, 110, 102, 102, 102, 110, 248, 0,254, 98, 96, 120, 96, 98, 254, 0,254, 98, 96, 120, 96, 96, 240, 0,62, 98, 192, 192, 206, 102, 62, 0,198, 198, 198, 254, 198, 198, 198, 0,60, 24, 24, 24, 24, 24, 60, 0,30, 12, 12, 12, 12, 204, 120, 0,230, 102, 108, 120, 120, 108, 230, 0,240, 96, 96, 96, 96, 102, 254, 0,198, 238, 254, 214, 198, 198, 198, 0,198, 230, 246, 254, 222, 206, 198, 0,124, 198, 198, 198, 198, 198, 124, 0,252, 102, 102, 124, 96, 96, 224, 0,124, 198, 198, 214, 222, 124, 6, 0,252, 102, 102, 124, 120, 108, 230, 0,124, 198, 224, 56, 14, 198, 124, 0,126, 90, 24, 24, 24, 24, 60, 0,102, 102, 102, 102, 102, 102, 60, 0,102, 102, 102, 102, 102, 60, 24, 0,198, 198, 198, 214, 254, 254, 198, 0,198, 108, 56, 56, 108, 198, 198, 0,102, 102, 102, 60, 24, 24, 60, 0,254, 204, 24, 48, 96, 198, 254, 0,60, 48, 48, 48, 48, 48, 60, 0,128, 192, 96, 48, 24, 12, 6, 0,60, 12, 12, 12, 12, 12, 60, 0,24, 60, 102, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 255,24, 24, 12, 0, 0, 0, 0, 0,0, 0, 56, 12, 124, 204, 118, 0,96, 96, 96, 124, 102, 102, 220, 0,0, 0, 124, 196, 192, 196, 124, 0,12, 12, 12, 124, 204, 204, 118, 0,0, 0, 120, 204, 252, 192, 124, 0,56, 108, 96, 248, 96, 96, 224, 0,0, 0, 118, 204, 204, 124, 12, 124,224, 96, 96, 124, 102, 102, 102, 0,48, 0, 112, 48, 48, 48, 56, 0,12, 0, 28, 12, 12, 204, 204, 120,224, 96, 102, 108, 120, 108, 102, 0,112, 48, 48, 48, 48, 48, 56, 0,0, 0, 204, 254, 214, 198, 198, 0,0, 0, 220, 102, 102, 102, 102, 0,0, 0, 60, 102, 102, 102, 60, 0,0, 0, 220, 102, 102, 124, 96, 224,0, 0, 118, 204, 204, 124, 12, 14,0, 0, 220, 118, 96, 96, 96, 0,0, 0, 120, 192, 120, 12, 120, 0,16, 48, 120, 48, 48, 52, 24, 0,0, 0, 204, 204, 204, 204, 118, 0,0, 0, 102, 102, 102, 60, 24, 0,0, 0, 198, 198, 214, 254, 108, 0,0, 0, 204, 120, 48, 120, 204, 0,0, 0, 204, 204, 204, 124, 12, 124,0, 0, 252, 24, 48, 96, 252, 0,14, 24, 24, 112, 24, 24, 14, 0,48, 48, 48, 0, 48, 48, 48, 0,112, 24, 24, 14, 24, 24, 112, 0,0, 118, 220, 0, 0, 0, 0, 0,16, 56, 108, 198, 198, 198, 254, 0 };void mode13hClass::character(int X0, int Y0, uchar LETTER, uchar COLOR){// IN ONE MOVE, TAKE THE ASCII CHARACTER OUT OF ROM AND INTO A VARIABLE.// IT'S FASTER TO MOVE IT ALL THAN IT IS TO LOOK IT UP EIGHT TIMES.char characterBuffer[8];_fmemcpy(characterBuffer, (charROM + (LETTER << 3)), 8);uchar far *pointer = buffer + (Y0<<8) + (Y0<<6) + X0;int Y=0;do{  char currentByte = *(characterBuffer + Y);  // LOOP UNROLLED.  TAKES CARE OF ONE HORIZONTAL LINE AT A TIME.  if(currentByte & 0x80) *pointer = COLOR;  if(currentByte & 0x40) *(pointer+1) = COLOR;  if(currentByte & 0x20) *(pointer+2) = COLOR;  if(currentByte & 0x10) *(pointer+3) = COLOR;  if(currentByte & 0x08) *(pointer+4) = COLOR;  if(currentByte & 0x04) *(pointer+5) = COLOR;  if(currentByte & 0x02) *(pointer+6) = COLOR;  if(currentByte & 0x01) *(pointer+7) = COLOR;  pointer += 320;}while(++Y<8);}void mode13hClass::string(int X0, int Y0, char *STRING, uchar COLOR){char left[128] = {   0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,  0, 2, 0, 0, 0, 0, 0, 1, 2, 2, 0, 1, 2, 1, 3, 0,  0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 2, 1,  0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 2, 0, 2, 1, 0,  3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1,  0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0 };char right[128] = { -2, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1,-1, 1, 1, 1,  0, 0,-1,-1, 1, 0, 0, 0,-1,-1, 0, 0, 0, 1, 0, 0, -3,-1,-1, 0, 0, 0, 0,-3,-1,-1, 0, 0,-2, 0,-2, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-1,-1,-1, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0,-1, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-1, 0,-1, 0, 1, -1, 0, 0,-1, 0,-1,-1, 0, 0,-2,-1, 0,-2, 0, 0, 0,  0, 0, 0,-1,-1, 0, 0, 0,-1,-1,-1, 0,-2, 0, 0, 0  };int Index = 0;int EndChar = strlen(STRING);do{  char LETTER = *(STRING + Index);  X0 -= *(left + LETTER);  character(X0, Y0, LETTER, COLOR);  X0 += *(right + LETTER) + 8;//delay(200);}while(++Index<EndChar);}void mode13hClass::stringWithDelay(int X0, int Y0, char *STRING, uchar COLOR, int DELAY){char left[128] = {   0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,  0, 2, 0, 0, 0, 0, 0, 1, 2, 2, 0, 1, 2, 1, 3, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 2, 1,  0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 2, 0, 2, 1, 0,  3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1,  0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0 };char right[128] = { -2, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1,-1, 1, 1, 1,  0, 0,-1,-1, 1, 0, 0, 0,-1,-1, 0, 0, 0, 1, 0, 0, -3,-1,-1, 0, 0, 0, 0,-3,-1,-1, 0, 0,-2, 0,-2, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-1,-1,-1, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0,-1, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-1, 0,-1, 0, 1, -1, 0, 0,-1, 0,-1,-1, 0, 0,-2,-1, 0,-2, 0, 0, 0,  0, 0, 0,-1,-1, 0, 0, 0,-1,-1,-1, 0,-2, 0, 0, 0  };int Index = 0;int EndChar = strlen(STRING);do{  char LETTER = *(STRING + Index);  X0 -= *(left + LETTER);  character(X0, Y0, LETTER, COLOR);  X0 += *(right + LETTER) + 8;  delay(DELAY);  displayFrame();}while(++Index<EndChar);}void mode13hClass::displayBuffer(){ready = 1;}void mode13hClass::displayFrame(){while(!ready);unsigned char far *s = (unsigned char far *)0xA0000000L;unsigned char far *b = buffer;while((inp(0x3DA) & 0x08));while(!(inp(0x3DA) & 0x08));asm {   push dsmov cx, 32000les di, slds si, bcldrep movswpop ds }ready = 0;}void mode13hClass::saveScreenPalette(){getColorRegisters(savedPalette);}void mode13hClass::copySavedPalette(){setColorRegisters(savedPalette);}void mode13hClass::setColorRegisters(uchar COLOR, uchar R, uchar G, uchar B){outp(0x3C6, 0xFF);outp(0x3C8, COLOR);outp(0x3C9, R);outp(0x3C9, G);outp(0x3C9, B);}void mode13hClass::setColorRegisters(const colorRegisterType ®S){outp(0x3C6, 0xFF);outp(0x3C8, REGS.COLOR);outp(0x3C9, REGS.RED);outp(0x3C9, REGS.GREEN);outp(0x3C9, REGS.BLUE);}void mode13hClass::setColorRegisters(const colorRegisterType *REGS){for(int Index=0; Index<256; Index++){  outp(0x3C6, 0xFF);  outp(0x3C8, REGS[Index].COLOR);  outp(0x3C9, REGS[Index].RED);  outp(0x3C9, REGS[Index].GREEN);  outp(0x3C9, REGS[Index].BLUE);}}void mode13hClass::getColorRegisters(uchar COL, uchar &R, uchar &G, uchar &B){outp(0x3C6, 0xFF);outp(0x3C7, COL);R = inp(0x3C9);G = inp(0x3C9);B = inp(0x3C9);}void mode13hClass::getColorRegisters(colorRegisterType ®S){outp(0x3C6, 0xFF);outp(0x3C7, REGS.COLOR);REGS.RED = inp(0x3C9);REGS.GREEN = inp(0x3C9);REGS.BLUE = inp(0x3C9);}void mode13hClass::getColorRegisters(colorRegisterType *REGS){for(int Index=0; Index<256; Index++){  outp(0x3C6, 0xFF);  outp(0x3C7, Index);  REGS[Index].COLOR = Index;  REGS[Index].RED = inp(0x3C9);  REGS[Index].GREEN = inp(0x3C9);  REGS[Index].BLUE = inp(0x3C9);}}void mode13hClass::fadeScreenToBlack(){for(int X=0; X<8; X++){  for(int I=0; I<256; I++)  {  uchar A, B, C;  getColorRegisters(I, A, B, C);  setColorRegisters(I, A*0.707107, B*0.707107, C*0.707107);  }  delay(600);}}void mode13hClass::bringScreenUpFromBlack(){float factors[8];float num = 1;for(int Index=7; Index>=0; Index--){factors[Index] = num;num *= 0.707107;}for(int X=0; X<8; X++){  for(int I=0; I<256; I++)  {  uchar A, B, C;  setColorRegisters(I, savedPalette.RED*factors[X],   savedPalette.GREEN*factors[X],   savedPalette.BLUE*factors[X]);  }  delay(600);}}void mode13hClass::candleEffect(int x, int y){x += 7;y += 15;int x0 = x - 40;int x1 = x - 16;int x2 = x + 32;int x3 = x + 56;int y0 = y - 36;int y1 = y - 8;int y2 = y + 40;int y3 = y + 64;if(x0<0) x0 = 0;if(x1<0) x1 = 0;if(y0<0) y0 = 0;if(y1<0) y1 = 0;if(x2>319) x2 = 319;if(x3>319) x3 = 319;if(y2>199) y2 = 199;if(y3>199) y3 = 199;filledRectangle(0, 0, 319, y0, 1);filledRectangle(0, y0, x0, 199, 1);filledRectangle(x3, y0, 319, 199, 1);filledRectangle(x0, y3, x3, 199, 1);for(int Xval=x0; Xval<=x3; Xval++)for(int Yval=y0; Yval<=y3; Yval++){int checkValue = ((Xval-x)*(Xval-x)) + ((Yval-y) * (Yval-y));if(checkValue>(36*36)) buffer[Yval*320+Xval] = 1;else if(checkValue>(20*20)) buffer[Yval*320+Xval] += 128;}}void mode13hClass::rectangle(unsigned X0, unsigned Y0, unsigned X1, unsigned Y1, uchar COLOR){line(X0, Y0, X1, Y0, COLOR);line(X1, Y0, X1, Y1, COLOR);line(X1, Y1, X0, Y1, COLOR);line(X0, Y1, X0, Y0, COLOR);}void mode13hClass::filledRectangle(unsigned X0, unsigned Y0, unsigned X1, unsigned Y1, uchar COLOR){if(Y0>Y1){unsigned temp = Y0;Y0 = Y1;Y1 = temp;}if(X0>X1){unsigned temp = X0;X0 = X1;X1 = temp;}uchar far *pointer = buffer + (Y0<<8) + (Y0<<6) + X0;unsigned length = X1 - X0 + 1;for(int I=Y0; I<=Y1; I++){  _fmemset(pointer, COLOR, length);  pointer += 320;}}void mode13hClass::saveScreenToPCX(char *FILENAME){FILE *pcxFileName = fopen(FILENAME, "wb");fputc(10, pcxFileName);fputc(5, pcxFileName);fputc(1, pcxFileName);fputc(8, pcxFileName);fputc(0, pcxFileName);fputc(0, pcxFileName);fputc(0, pcxFileName);fputc(0, pcxFileName);fputc(0x3F, pcxFileName);   fputc(1, pcxFileName);    // 319fputc(0xC7, pcxFileName);   fputc(0, pcxFileName);    // 199fputc(0x40, pcxFileName);   fputc(1, pcxFileName);    // 320fputc(0xC8, pcxFileName);   fputc(0, pcxFileName);    // 200for(int Index=0; Index<112; Index++){  fputc(0, pcxFileName);}for(int Y=0; Y<200; Y++){  unsigned location = (320 * Y);  unsigned endOfLine = location + 320;  int bytesLeft = 320;  while(bytesLeft > 0)  {  uchar data = *(buffer+location);  location++;  if(data >=192)  {    fputc(193, pcxFileName);    fputc(data, pcxFileName);    bytesLeft--;  }  else  {    unsigned runLength = 1;    unsigned done = 0;    while(!done && runLength<63 && location<endOfLine)    { uchar moreData = *(buffer + location); if(data != moreData) { done=1; } else { runLength++; location++; }    }    if(runLength == 1)    { fputc(data, pcxFileName); bytesLeft--;    }    else    { fputc(192+runLength, pcxFileName); fputc(data, pcxFileName); bytesLeft -= runLength;    }  }  }}for(Index=0; Index<256; Index++){  uchar red, green, blue;  getColorRegisters(Index, red, green, blue);  fputc(red<<2, pcxFileName);  fputc(green<<2, pcxFileName);  fputc(blue<<2, pcxFileName);}fclose(pcxFileName);}/*#include <conio.h>void main(){mode13hClass screen;screen.setVideoMode(0x13);screen.clearScreen(15);screen.setPixel(160, 100, 0);int num = 0;int dir = 1;while(!kbhit()){  if(dir==0)  {  --num;  if(num==0)  {    dir=1;  }  }  else  {  ++num;  if(num==63)  {   dir=0;  }  }  screen.setColorRegisters(15, num, num, num);  screen.line(0,0,319,199, 8);  screen.string(10, 10, "abcdefghijklmnopq", 6);  screen.displayFrame();}screen.setVideoMode(3);}*/mode13.h#ifndef MODE13_H#define MODE13_H#include "\doscla~1\kernel\kernel.h"#define uchar unsigned chartypedef struct {    uchar COLOR;    uchar RED;    uchar GREEN;    uchar BLUE;  } colorRegisterType;class mode13hClass: public kernelClass{  public:static unsigned char far *buffer;static unsigned numberOfInstances;static unsigned ready;static colorRegisterType savedPalette[256];static int RIGHT_EXTENT;static int BOTTOM_EXTENT;static int TOP_EXTENT;static int LEFT_EXTENT;static int cameraX;static int cameraY;mode13hClass();void setVideoMode(unsigned);void setScreenToMode13h();void setScreenToTextMode();void setPixel(unsigned, unsigned, uchar);uchar getPixel(unsigned, unsigned);void candleEffect(int x, int y);void line(unsigned, unsigned, unsigned, unsigned, uchar);void rectangle(unsigned, unsigned, unsigned, unsigned, uchar);void filledRectangle(unsigned, unsigned, unsigned, unsigned, uchar);void clearScreen(uchar);static void displayBuffer();static void displayFrame();void character(int X0, int Y0, uchar LETTER, uchar COLOR);void string(int X0, int Y0, char *STRING, uchar COLOR);void stringWithDelay(int, int, char *, uchar, int);void setColorRegisters(uchar, uchar, uchar, uchar);void setColorRegisters(const colorRegisterType &);void setColorRegisters(const colorRegisterType *);void fadeScreenToBlack();void bringScreenUpFromBlack();void getColorRegisters(uchar COL, uchar &, uchar &, uchar &);void getColorRegisters(colorRegisterType &);void getColorRegisters(colorRegisterType *);void saveScreenPalette();void copySavedPalette();void saveScreenToPCX(char *FILENAME);~mode13hClass();};#endif