/* * tsr.h * ***************************************************************************** * * Memory only - Console functions for TSRs * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ***************************************************************************** * * Author : Rajesh _ThE gReAt * Built on : forgotten! (some time in 2k) * Last Modified on : Friday, February 08, 2002, 3:55:16 PM * * Known errors : Almost all functions access memory directly . * Do not try to compile in any OS other than DOS. * ***************************************************************************** * DISCLAIMER: ***************************************************************************** * * Programmers may incorporate any or all code into their programs, * giving proper credit within the source. Publication of the * source routines is permitted so long as proper credit is given * to Rajesh _ThE gReAt. * * Copyright (C) 2002, 2003 by Rajesh _ThE gReAt. You may use this program, or * code or tables extracted from it, as desired without restriction. * I can not and will not be held responsible for any damage caused from * the use of this software. * * Read license.txt from http://www.rajeshgoli.com/license.txt * or http://www.rajeshgoli.com/license.htm * before using / distributing / or any sort of use of my source * Also read my disclaimer http://www.rajeshgoli.com/disclaimer.htm * * YOU AGREE TO BE BOUND BY MY DISCLAIMER AND LICENSE BY IN ANY WAY * USING THIS FILE . * ***************************************************************************** * This source works with Turbo C 2.0 and Turbo C++ 3.0 and above. ***************************************************************************** * Rajesh _ThE gReAt is a synonym of Rajesh Goli * Source freely distributable *****************************************************************************/ #ifndef __DOS_H #include #endif #ifdef __TSRS_H #error Cant include both tsr.h and tsrs.h #endif #ifndef __TSR_H #define __TSR_H #endif #define _BOX_ typedef unsigned char byte; union REGS input,output; struct SREGS sregisters; unsigned short r,c,k; byte far *scr = (byte far *)0xB8000000L; byte *buffer; void writestring (char *,unsigned short ,unsigned short ,byte ); void writechar (char ,unsigned short ,unsigned short ,byte ); void clrwin (unsigned short ,unsigned short ,unsigned short ,unsigned short ,byte ); void savewin (unsigned short ,unsigned short ,unsigned short ,unsigned short ); void restorewin (unsigned short ,unsigned short ,unsigned short ,unsigned short ); void box (unsigned short ,unsigned short ,unsigned short ,unsigned short ,byte ,byte ); void writecolor (unsigned short ,unsigned short ,byte ); /************************************************/ /* Fuction 2 write a string to VDU memory */ /************************************************/ void writestring(char *str,unsigned short row,unsigned short col,byte attrb) { while(*str) { writechar(*str,row,col,attrb); str++; col++; } return; } /************************************************/ /**********************************************/ /* Function 2 write a charecter to VDU memory */ /**********************************************/ void writechar(char ch,unsigned short row,unsigned short col,byte attrb) { *(scr+(row*160)+(col*2)) = ch; *(scr+(row*160)+(col*2)+1) = attrb; return; } /***********************************************/ /**********************************/ /* Clears window */ /**********************************/ void clrwin(unsigned short sr,unsigned short sc,unsigned short er,unsigned short ec,byte attrb) { input.h.ah = 6; input.h.al = 0; input.h.ch = sr; input.h.cl = sc; input.h.dh = er; input.h.dl = ec; input.h.bh = attrb; int86(0x10,&input,&output); return; } /**********************************/ /***********************************************************/ /* Function 2 save charecters in VDU memory */ /***********************************************************/ void savewin(unsigned short sr,unsigned short sc,unsigned short er,unsigned short ec) { for(k=0,r=sr;r<=er;r++) { for(c=sc;c<=ec;c++) { buffer[k]=*(scr+(r*160)+(c*2)); buffer[k+1]=*(scr+(r*160)+(c*2)+1); k += 2; } } return; } /***********************************************************/ /***********************************************************/ /* Function 2 save charecters to VDU memory */ /***********************************************************/ void restorewin(unsigned short sr,unsigned short sc,unsigned short er,unsigned short ec) { for(k=0,r=sr;r<=er;r++) { for(c=sc;c<=ec;c++) { *(scr+(r*160)+(c*2)) = buffer[k]; *(scr+(r*160)+(c*2)+1) = buffer[k+1]; k += 2; } } return; } /***********************************************************/ unsigned short rr,cc; void box(unsigned short r1,unsigned short c1,unsigned short r2,unsigned short c2,byte attrb,byte shadow) { clrwin(r1,c1,r2,c2,attrb); writechar(201,r1,c1,attrb); writechar(187,r1,c2,attrb); writechar(200,r2,c1,attrb); writechar(188,r2,c2,attrb); for(rr=r1+1;rr