├── BGIHDR.COM ├── README.md ├── SVGA16.BGI ├── SVGA256.BGI ├── SVGA32K.BGI ├── SVGA64K.BGI ├── SVGAS3.BGI ├── SVGATC.BGI ├── TWK16.BGI ├── TWK256.BGI ├── TWKTEXT.BGI ├── VGADEMO.EXE ├── INITSVGA.PRJ ├── REGISTER.DOC ├── BGI30 ├── SVGA16.BGX ├── SVGAS3.BGX ├── SVGATC.BGX ├── TWK16.BGX ├── TWK256.BGX ├── SVGA256.BGX ├── SVGA32K.BGX ├── SVGA64K.BGX ├── TWKTEXT.BGX └── README ├── MOUSE ├── TMOUSE.COM ├── HGXMOUSE.EXE ├── MOUSTEST.EXE ├── SOURCE │ ├── HGXMOUSE.ASM │ └── DOSMACRO.INC ├── CONTENTS.LST └── HGXMOUSE.DOC ├── SOURCE ├── TWK16.ASM ├── SVGA16.ASM ├── SVGABANK.INC ├── S3CODE.INC ├── MACROS.INC ├── VGADAC.INC ├── COMMON.INC ├── TWKTEXT.ASM └── TWK256.ASM ├── SVGA_VER.DB ├── TWK256.INC ├── SVGAS3.INC ├── TWK16.INC ├── TWK256.H ├── SVGA256.INC ├── SVGA16.INC ├── SVGA32K.INC ├── SVGA64K.INC ├── MAKEFILE.TWK ├── SVGATC.INC ├── TWK16.H ├── SVGA256.H ├── SVGA16.H ├── SVGA32K.H ├── SVGA64K.H ├── SVGATC.H ├── SVGAS3.H ├── NOTES16.TWK ├── MAKEBGI.BAT ├── LICENSE ├── MAKEFILE.SVG ├── NOTES256.TWK ├── ERROR.LOG ├── SVGAUTIL.H ├── BGIHDR.H ├── SHAREWRE.TXT ├── NOTES16.SVG ├── NOTES256.SVG ├── SVGAUTIL.INC ├── NOTES_S3.SVG ├── NOTESTC.SVG ├── NOTES64K.SVG ├── FAQ.DOC ├── NOTES32K.SVG ├── INITSVGA.PAS ├── INITSVGA.C ├── SVGAUTIL.C └── BGIHDR.CPP /BGIHDR.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/BGIHDR.COM -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/README.md -------------------------------------------------------------------------------- /SVGA16.BGI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/SVGA16.BGI -------------------------------------------------------------------------------- /SVGA256.BGI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/SVGA256.BGI -------------------------------------------------------------------------------- /SVGA32K.BGI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/SVGA32K.BGI -------------------------------------------------------------------------------- /SVGA64K.BGI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/SVGA64K.BGI -------------------------------------------------------------------------------- /SVGAS3.BGI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/SVGAS3.BGI -------------------------------------------------------------------------------- /SVGATC.BGI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/SVGATC.BGI -------------------------------------------------------------------------------- /TWK16.BGI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/TWK16.BGI -------------------------------------------------------------------------------- /TWK256.BGI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/TWK256.BGI -------------------------------------------------------------------------------- /TWKTEXT.BGI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/TWKTEXT.BGI -------------------------------------------------------------------------------- /VGADEMO.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/VGADEMO.EXE -------------------------------------------------------------------------------- /INITSVGA.PRJ: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/INITSVGA.PRJ -------------------------------------------------------------------------------- /REGISTER.DOC: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/REGISTER.DOC -------------------------------------------------------------------------------- /BGI30/SVGA16.BGX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/BGI30/SVGA16.BGX -------------------------------------------------------------------------------- /BGI30/SVGAS3.BGX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/BGI30/SVGAS3.BGX -------------------------------------------------------------------------------- /BGI30/SVGATC.BGX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/BGI30/SVGATC.BGX -------------------------------------------------------------------------------- /BGI30/TWK16.BGX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/BGI30/TWK16.BGX -------------------------------------------------------------------------------- /BGI30/TWK256.BGX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/BGI30/TWK256.BGX -------------------------------------------------------------------------------- /MOUSE/TMOUSE.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/MOUSE/TMOUSE.COM -------------------------------------------------------------------------------- /SOURCE/TWK16.ASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/SOURCE/TWK16.ASM -------------------------------------------------------------------------------- /BGI30/SVGA256.BGX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/BGI30/SVGA256.BGX -------------------------------------------------------------------------------- /BGI30/SVGA32K.BGX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/BGI30/SVGA32K.BGX -------------------------------------------------------------------------------- /BGI30/SVGA64K.BGX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/BGI30/SVGA64K.BGX -------------------------------------------------------------------------------- /BGI30/TWKTEXT.BGX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/BGI30/TWKTEXT.BGX -------------------------------------------------------------------------------- /MOUSE/HGXMOUSE.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/MOUSE/HGXMOUSE.EXE -------------------------------------------------------------------------------- /MOUSE/MOUSTEST.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/MOUSE/MOUSTEST.EXE -------------------------------------------------------------------------------- /SOURCE/SVGA16.ASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/SOURCE/SVGA16.ASM -------------------------------------------------------------------------------- /SOURCE/SVGABANK.INC: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/SOURCE/SVGABANK.INC -------------------------------------------------------------------------------- /MOUSE/SOURCE/HGXMOUSE.ASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jharg93/SvgaBGI/HEAD/MOUSE/SOURCE/HGXMOUSE.ASM -------------------------------------------------------------------------------- /BGI30/README: -------------------------------------------------------------------------------- 1 | These are the BGIv3.0 drivers for 16-bit protected mode. 2 | They are used by Turbo Pascal 7.0 and Borland PowerPack. 3 | Rename xxx.BGX to xxx.BGI for use with TP/BP 7.0. 4 |  -------------------------------------------------------------------------------- /SVGA_VER.DB: -------------------------------------------------------------------------------- 1 | svga16 2.10 ;; BGIv3.0 2 | svga256 3.10 ;; BGIv3.0 3 | svga32k 1.60 ;; BGIv3.0 4 | svga64k 1.60 ;; BGIv3.0 5 | svgas3 1.60 ;; BGIv3.0 6 | svgatc 1.10 ;; BGIv3.0 7 | twk16 1.60 ;; BGIv3.0 8 | twk256 1.60 ;; BGIv3.0 9 |  -------------------------------------------------------------------------------- /MOUSE/CONTENTS.LST: -------------------------------------------------------------------------------- 1 | Files included in this distribution: 2 | 3 | hgxmouse.exe - HGXMOUSE TSR Executable 4 | tmouse.com - Text mode cursor initialization program 5 | (does an int 0x33, function 0x4500 with BL=6) 6 | moustest.exe - Mouse test program (requires mouse enabled BGI drivers) 7 | hgxmouse.doc - HGXMOUSE Documentation 8 |  -------------------------------------------------------------------------------- /TWK256.INC: -------------------------------------------------------------------------------- 1 | (************************************************) 2 | (* *) 3 | (* Tweaked 256 BGI driver defines *) 4 | (* Copyright (c) 1991 *) 5 | (* Jordan Hargraphix Software *) 6 | (* *) 7 | (************************************************) 8 | 9 | (* These are the currently supported modes *) 10 | const 11 | TWK320x400x256 = 0; 12 | TWK320x480x256 = 1; 13 | TWK360x480x256 = 2; 14 | TWK376x564x256 = 3; 15 | TWK400x564x256 = 4; 16 | TWK400x600x256 = 5; 17 | TWK320x240x256 = 6; 18 | 19 |  -------------------------------------------------------------------------------- /SVGAS3.INC: -------------------------------------------------------------------------------- 1 | (************************************************) 2 | (* *) 3 | (* SuperVGA S3 BGI driver defines *) 4 | (* Copyright (c) 1992 *) 5 | (* Jordan Hargraphix Software *) 6 | (* *) 7 | (************************************************) 8 | 9 | (* These are the currently supported modes *) 10 | const 11 | SVGAS3_640x480x256 = 0; 12 | SVGAS3_800x600x256 = 1; 13 | SVGAS3_1024x768x256 = 2; 14 | SVGAS3_800x600x16 = 3; 15 | SVGAS3_1024x768x16 = 4; 16 | SVGAS3_1280x960x16 = 5; 17 | SVGAS3_1280x1024x16 = 6; 18 | SVGAS3_640x480x32768 = 7; 19 | 20 |  -------------------------------------------------------------------------------- /TWK16.INC: -------------------------------------------------------------------------------- 1 | (************************************************) 2 | (* *) 3 | (* SuperVGA 16 BGI driver defines *) 4 | (* Copyright (c) 1991 *) 5 | (* Jordan Hargraphix Software *) 6 | (* *) 7 | (************************************************) 8 | 9 | (* These are the currently supported modes *) 10 | const 11 | TWK704x528x16 = 0; (* 704x528x16 Tweaked VGA *) 12 | TWK720x540x16 = 1; (* 720x540x16 Tweaked VGA *) 13 | TWK736x552x16 = 2; (* 736x552x16 Tweaked VGA *) 14 | TWK752x564x16 = 3; (* 752x564x16 Tweaked VGA *) 15 | TWK784x588x16 = 4; (* 784x588x16 Tweaked VGA *) 16 | TWK800x600x16 = 5; (* 800x600x16 Tweaked VGA *) 17 | 18 |  -------------------------------------------------------------------------------- /TWK256.H: -------------------------------------------------------------------------------- 1 | /************************************************/ 2 | /* */ 3 | /* Tweaked 256 BGI driver defines */ 4 | /* Copyright (c) 1991 */ 5 | /* Jordan Hargraphix Software */ 6 | /* */ 7 | /************************************************/ 8 | 9 | #ifndef __TWK256_H__ 10 | #define __TWK256_H__ 11 | 12 | extern int far _Cdecl Twk256_fdriver[]; 13 | 14 | /* These are the currently supported modes */ 15 | #define TWK320x400x256 0 16 | #define TWK320x480x256 1 17 | #define TWK360x480x256 2 18 | #define TWK376x564x256 3 19 | #define TWK400x564x256 4 20 | #define TWK400x600x256 5 21 | #define TWK320x240x256 6 22 | 23 | #endif /* __TWK256_H__ */ 24 |  -------------------------------------------------------------------------------- /SVGA256.INC: -------------------------------------------------------------------------------- 1 | (************************************************) 2 | (* *) 3 | (* SuperVGA 256 BGI driver defines *) 4 | (* Copyright (c) 1991 *) 5 | (* Jordan Hargraphix Software *) 6 | (* *) 7 | (************************************************) 8 | 9 | (* These are the currently supported modes *) 10 | const 11 | SVGA320x200x256 = 0; (* 320x200x256 Standard VGA *) 12 | SVGA640x400x256 = 1; (* 640x400x256 Svga *) 13 | SVGA640x480x256 = 2; (* 640x480x256 Svga *) 14 | SVGA800x600x256 = 3; (* 800x600x256 Svga *) 15 | SVGA1024x768x256 = 4; (* 1024x768x256 Svga *) 16 | SVGA640x350x256 = 5; (* 640x350x256 Svga *) 17 | SVGA1280x1024x256 = 6; (* 1280x1024x256 Svga *) 18 | 19 |  -------------------------------------------------------------------------------- /SVGA16.INC: -------------------------------------------------------------------------------- 1 | (************************************************) 2 | (* *) 3 | (* SuperVGA 16 BGI driver defines *) 4 | (* Copyright (c) 1991 *) 5 | (* Jordan Hargraphix Software *) 6 | (* *) 7 | (************************************************) 8 | 9 | (* These are the currently supported modes *) 10 | const 11 | SVGA320x200x16 = 0; (* 320x200x16 Standard EGA/VGA *) 12 | SVGA640x200x16 = 1; (* 640x200x16 Standard EGA/VGA *) 13 | SVGA640x350x16 = 2; (* 640x350x16 Standard EGA/VGA *) 14 | SVGA640x480x16 = 3; (* 640x480x16 Standard VGA *) 15 | SVGA800x600x16 = 4; (* 800x600x16 SuperVGA/VESA *) 16 | SVGA1024x768x16 = 5; (* 1024x768x16 SuperVGA/VESA *) 17 | SVGA1280x1024x16 = 6; (* 1280x1024x16 SuperVGA/VESA *) 18 | 19 |  -------------------------------------------------------------------------------- /SVGA32K.INC: -------------------------------------------------------------------------------- 1 | (************************************************) 2 | (* *) 3 | (* SuperVGA 32768 BGI driver defines *) 4 | (* Copyright (c) 1991 *) 5 | (* Jordan Hargraphix Software *) 6 | (* *) 7 | (************************************************) 8 | 9 | (* These are the currently supported modes *) 10 | const 11 | SVGA320x200x32768 = 0; (* 320x200x32768 HiColor VGA *) 12 | SVGA640x350x32768 = 1; (* 640x350x32768 HiColor VGA *) 13 | SVGA640x400x32768 = 2; (* 640x400x32768 HiColor VGA *) 14 | SVGA640x480x32768 = 3; (* 640x480x32768 HiColor VGA *) 15 | SVGA800x600x32768 = 4; (* 800x600x32768 HiColor VGA *) 16 | SVGA1024x768x32768 = 5; (* 1024x768x32768 HiColor VGA *) 17 | SVGA1280x1024x32768 = 6; (* 1280x1024x32768 HiColor VGA *) 18 | 19 |  -------------------------------------------------------------------------------- /SVGA64K.INC: -------------------------------------------------------------------------------- 1 | (************************************************) 2 | (* *) 3 | (* SuperVGA 65536 BGI driver defines *) 4 | (* Copyright (c) 1993 *) 5 | (* Jordan Hargraphix Software *) 6 | (* *) 7 | (************************************************) 8 | 9 | (* These are the currently supported modes *) 10 | const 11 | SVGA320x200x65536 = 0; (* 320x200x65536 HiColor VGA *) 12 | SVGA640x350x65536 = 1; (* 640x350x65536 HiColor VGA *) 13 | SVGA640x400x65536 = 2; (* 640x400x65536 HiColor VGA *) 14 | SVGA640x480x65536 = 3; (* 640x480x65536 HiColor VGA *) 15 | SVGA800x600x65536 = 4; (* 800x600x65536 HiColor VGA *) 16 | SVGA1024x768x65536 = 5; (* 1024x768x65536 HiColor VGA *) 17 | SVGA1280x1024x65536 = 6; (* 1280x1024x65536 HiColor VGA *) 18 | 19 |  -------------------------------------------------------------------------------- /MAKEFILE.TWK: -------------------------------------------------------------------------------- 1 | ## Makefile for initsvga.c (Tweaked drivers) 2 | ## Demonstrates use of registerfarbgidriver 3 | PROG = initsvga # Program name to compile 4 | CC = tcc # Command-line compiler (tcc/bcc) 5 | LIB = e:\lang\lib # Library directory 6 | INCLUDE = e:\lang\include # Include directory 7 | MODEL = s # Memory Model 8 | 9 | $(PROG).exe: $(PROG).c twk256f.obj twk16f.obj 10 | $(CC) -L$(LIB) -I$(INCLUDE) -m$(MODEL) $(PROG).c \ 11 | twk256f.obj twk16f.obj graphics.lib 12 | 13 | twk256f.obj : twk256.bgi 14 | bgiobj /F twk256.bgi twk256f.obj _twk256_fdriver TWK256_TEXT 15 | 16 | twk16f.obj : twk16.bgi 17 | bgiobj /F twk16.bgi twk16f.obj _twk16_fdriver TWK16_TEXT 18 | 19 | twktextf.obj : twktext.bgi 20 | bgiobj /F twktext.bgi twktextf.obj _twktext_fdriver TWKTEXT_TEXT 21 |  -------------------------------------------------------------------------------- /SVGATC.INC: -------------------------------------------------------------------------------- 1 | (************************************************) 2 | (* *) 3 | (* SuperVGA 24-bit BGI driver defines *) 4 | (* Copyright (c) 1991 *) 5 | (* Jordan Hargraphix Software *) 6 | (* *) 7 | (************************************************) 8 | 9 | (* These are the currently supported modes *) 10 | const 11 | SVGA320x200x24_bit = 0; (* 320x200x24-bit TrueColor VGA *) 12 | SVGA640x350x24_bit = 1; (* 640x350x24-bit TrueColor VGA *) 13 | SVGA640x400x24_bit = 2; (* 640x400x24-bit TrueColor VGA *) 14 | SVGA640x480x24_bit = 3; (* 640x480x24-bit TrueColor VGA *) 15 | SVGA800x600x24_bit = 4; (* 800x600x24-bit TrueColor VGA *) 16 | SVGA1024x768x24_bit = 5; (* 1024x768x24-bit TrueColor VGA *) 17 | SVGA1280x1024x24_bit = 6; (* 1280x1024x24-bit TrueColor VGA *) 18 | 19 |  -------------------------------------------------------------------------------- /TWK16.H: -------------------------------------------------------------------------------- 1 | /************************************************/ 2 | /* */ 3 | /* Tweaked 16 BGI driver defines */ 4 | /* Copyright (c) 1991 */ 5 | /* Jordan Hargraphix Software */ 6 | /* */ 7 | /************************************************/ 8 | 9 | #ifndef __TWK16_H__ 10 | #define __TWK16_H__ 11 | 12 | extern int far Twk16_fdriver[]; 13 | 14 | /* These are the currently supported modes */ 15 | #define TWK704x528x16 0 /* 704x528x16 Tweaked VGA */ 16 | #define TWK720x540x16 1 /* 720x540x16 Tweaked VGA */ 17 | #define TWK736x552x16 2 /* 736x552x16 Tweaked VGA */ 18 | #define TWK752x564x16 3 /* 752x564x16 Tweaked VGA */ 19 | #define TWK784x588x16 4 /* 784x588x16 Tweaked VGA */ 20 | #define TWK800x600x16 5 /* 800x600x16 Tweaked VGA */ 21 | 22 | #endif /* __TWK16_H__ */ 23 |  -------------------------------------------------------------------------------- /SVGA256.H: -------------------------------------------------------------------------------- 1 | /************************************************/ 2 | /* */ 3 | /* SuperVGA 256 BGI driver defines */ 4 | /* Copyright (c) 1991 */ 5 | /* Jordan Hargraphix Software */ 6 | /* */ 7 | /************************************************/ 8 | 9 | #ifndef __SVGA256_H__ 10 | #define __SVGA256_H__ 11 | 12 | extern int far _Cdecl Svga256_fdriver[]; 13 | 14 | /* These are the currently supported modes */ 15 | #define SVGA320x200x256 0 /* 320x200x256 Standard VGA */ 16 | #define SVGA640x400x256 1 /* 640x400x256 Svga/VESA */ 17 | #define SVGA640x480x256 2 /* 640x480x256 Svga/VESA */ 18 | #define SVGA800x600x256 3 /* 800x600x256 Svga/VESA */ 19 | #define SVGA1024x768x256 4 /* 1024x768x256 Svga/VESA */ 20 | #define SVGA640x350x256 5 /* 640x350x256 Svga/VESA */ 21 | #define SVGA1280x1024x256 6 /* 1280x1024x256 Svga/VESA */ 22 | 23 | #endif /* __SVGA256_H__ */ 24 |  -------------------------------------------------------------------------------- /SVGA16.H: -------------------------------------------------------------------------------- 1 | /************************************************/ 2 | /* */ 3 | /* SuperVGA 16 BGI driver defines */ 4 | /* Copyright (c) 1991 */ 5 | /* Jordan Hargraphix Software */ 6 | /* */ 7 | /************************************************/ 8 | 9 | #ifndef __SVGA16_H__ 10 | #define __SVGA16_H__ 11 | 12 | extern int far Svga16_fdriver[]; 13 | 14 | /* These are the currently supported modes */ 15 | #define SVGA320x200x16 0 /* 320x200x16 Standard EGA/VGA */ 16 | #define SVGA640x200x16 1 /* 640x200x16 Standard EGA/VGA */ 17 | #define SVGA640x350x16 2 /* 640x350x16 Standard EGA/VGA */ 18 | #define SVGA640x480x16 3 /* 640x480x16 Standard VGA */ 19 | #define SVGA800x600x16 4 /* 800x600x16 SuperVGA/VESA */ 20 | #define SVGA1024x768x16 5 /* 1024x768x16 SuperVGA/VESA */ 21 | #define SVGA1280x1024x16 6 /* 1280x1024x16 SuperVGA/VESA */ 22 | 23 | #endif /* __SVGA16_H__ */ 24 |  -------------------------------------------------------------------------------- /SVGA32K.H: -------------------------------------------------------------------------------- 1 | /************************************************/ 2 | /* */ 3 | /* SuperVGA 32768 BGI driver defines */ 4 | /* Copyright (c) 1991 */ 5 | /* Jordan Hargraphix Software */ 6 | /* */ 7 | /************************************************/ 8 | 9 | #ifndef __SVGA32K_H__ 10 | #define __SVGA32K_H__ 11 | 12 | extern int far _Cdecl Svga32k_fdriver[]; 13 | 14 | /* These are the currently supported modes */ 15 | #define SVGA320x200x32768 0 /* 320x200x32768 HiColor VGA */ 16 | #define SVGA640x350x32768 1 /* 640x350x32768 HiColor VGA */ 17 | #define SVGA640x400x32768 2 /* 640x400x32768 HiColor VGA */ 18 | #define SVGA640x480x32768 3 /* 640x480x32768 HiColor VGA */ 19 | #define SVGA800x600x32768 4 /* 800x600x32768 HiColor VGA */ 20 | #define SVGA1024x768x32768 5 /* 1024x768x32768 HiColor VGA */ 21 | #define SVGA1280x1024x32768 6 /* 1280x1024x32768 HiColor VGA */ 22 | 23 | #endif /* __SVGA32K_H__ */ 24 |  -------------------------------------------------------------------------------- /SVGA64K.H: -------------------------------------------------------------------------------- 1 | /************************************************/ 2 | /* */ 3 | /* SuperVGA 65536 BGI driver defines */ 4 | /* Copyright (c) 1993 */ 5 | /* Jordan Hargraphix Software */ 6 | /* */ 7 | /************************************************/ 8 | 9 | #ifndef __SVGA64K_H__ 10 | #define __SVGA64K_H__ 11 | 12 | extern int far _Cdecl Svga64k_fdriver[]; 13 | 14 | /* These are the currently supported modes */ 15 | #define SVGA320x200x65536 0 /* 320x200x65536 HiColor VGA */ 16 | #define SVGA640x350x65536 1 /* 640x350x65536 HiColor VGA */ 17 | #define SVGA640x400x65536 2 /* 640x400x65536 HiColor VGA */ 18 | #define SVGA640x480x65536 3 /* 640x480x65536 HiColor VGA */ 19 | #define SVGA800x600x65536 4 /* 800x600x65536 HiColor VGA */ 20 | #define SVGA1024x768x65536 5 /* 1024x768x65536 HiColor VGA */ 21 | #define SVGA1280x1024x65536 6 /* 1280x1024x65536 HiColor VGA */ 22 | 23 | #endif /* __SVGA64K_H__ */ 24 |  -------------------------------------------------------------------------------- /SVGATC.H: -------------------------------------------------------------------------------- 1 | /************************************************/ 2 | /* */ 3 | /* SuperVGA TrueColor BGI driver defines */ 4 | /* Copyright (c) 1994 */ 5 | /* Jordan Hargraphix Software */ 6 | /* */ 7 | /************************************************/ 8 | 9 | #ifndef __SVGATC_H__ 10 | #define __SVGATC_H__ 11 | 12 | extern int far _Cdecl SvgaTC_fdriver[]; 13 | 14 | /* These are the currently supported modes */ 15 | #define SVGA320x200x24bit 0 /* 320x200x24bit TrueColor VGA */ 16 | #define SVGA640x350x24bit 1 /* 640x350x24bit TrueColor VGA */ 17 | #define SVGA640x400x24bit 2 /* 640x400x24bit TrueColor VGA */ 18 | #define SVGA640x480x24bit 3 /* 640x480x24bit TrueColor VGA */ 19 | #define SVGA800x600x24bit 4 /* 800x600x24bit TrueColor VGA */ 20 | #define SVGA1024x768x24bit 5 /* 1024x768x24bit TrueColor VGA */ 21 | #define SVGA1280x1024x24bit 6 /* 1280x1024x24bit TrueColor VGA */ 22 | 23 | #endif /* __SVGATC_H__ */ 24 |  -------------------------------------------------------------------------------- /SVGAS3.H: -------------------------------------------------------------------------------- 1 | /************************************************/ 2 | /* */ 3 | /* SuperVGA S3 BGI driver defines */ 4 | /* Copyright (c) 1992 */ 5 | /* Jordan Hargraphix Software */ 6 | /* */ 7 | /************************************************/ 8 | 9 | #ifndef __SVGAS3_H__ 10 | #define __SVGAS3_H__ 11 | 12 | extern int far _Cdecl SvgaS3_fdriver[]; 13 | 14 | /* These are the currently supported modes */ 15 | #define SVGAS3_640x480x256 0 /* 640x480x256 S3 Svga */ 16 | #define SVGAS3_800x600x256 1 /* 800x600x256 S3 Svga */ 17 | #define SVGAS3_1024x768x256 2 /* 1024x768x256 S3 Svga */ 18 | #define SVGAS3_800x600x16 3 /* 800x600x16 S3 Svga */ 19 | #define SVGAS3_1024x768x16 4 /* 1024x768x16 S3 Svga */ 20 | #define SVGAS3_1280x960x16 5 /* 1280x960x16 S3 Svga */ 21 | #define SVGAS3_1280x1024x16 6 /* 1280x1024x16 S3 Svga */ 22 | #define SVGAS3_640x480x32768 7 /* 640x480x32768 S3 HiColor Svga */ 23 | 24 | #endif /* __SVGAS3_H__ */ 25 |  -------------------------------------------------------------------------------- /NOTES16.TWK: -------------------------------------------------------------------------------- 1 | TweakVGA 16 BGI driver 2 | Version 1.7 3 | August 23, 1994 4 | 5 | Revisions: 6 | 1.7 - August 23, 1994 7 | 1.65 - July 20, 1994 8 | 1.5 - August 28, 1993 9 | 1.2 - May 21, 1993 10 | 1.15 - January 28, 1993 11 | 1.1 - August 20, 1991 12 | 13 | This is the latest version of my 16 color tweaked BGI driver. All functions 14 | have been implemented (including floodfill), and should work like 15 | the EGAVGA driver. 16 | 17 | NOTES: Paging and mouse cursor will not work 18 | The mouse cursor will work if the HGXMOUSE TSR is loaded. 19 | 20 | o Mouse code hooks added (1.15) 21 | 22 | o Fixed text clipping at right and bottom edges (1.2) 23 | 24 | o Added compile-time support for 8x8, 8x14, or 8x16 bitmap fonts (1.2) 25 | 26 | o Drivers now have compile-time support for BGI version 3.0. 27 | Supports protected mode with Borland Pascal 7.0 (1.5) 28 | 29 | o Integrated support for HGXMOUSE mouse cursor TSR. (1.65) 30 | 31 |  -------------------------------------------------------------------------------- /MAKEBGI.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | SET BGIVER=2 3 | if "%1" == "" goto SelectType 4 | if "%3" == "" goto setBGIVer 5 | set BGIVER= 6 | set BGIVER=%3 7 | :setBGIVer 8 | if %1 == t goto makeTweak 9 | if %1 == s goto makeSuperVGA 10 | goto SelectType 11 | 12 | :makeSuperVGA 13 | tasm /dBGIVERSION=%BGIVER% SVGA%2.asm,SVGA%2.obj ; 14 | tlink /3 SVGA%2.obj 15 | exe2bin SVGA%2.exe SVGA%2.bin 16 | bgihdr SVGA%2 SVGA%2.bin SVGA%2.bgi SVGA%2.map 17 | del SVGA%2.exe 18 | del SVGA%2.obj 19 | del SVGA%2.bin 20 | del SVGA%2.map 21 | goto Exit 22 | 23 | :makeTweak 24 | tasm /dBGIVERSION=%BGIVER% TWK%2.asm,TWK%2.obj ; 25 | tlink /3 TWK%2.obj 26 | exe2bin TWK%2.exe TWK%2.bin 27 | bgihdr TWK%2 TWK%2.bin TWK%2.bgi TWK%2.map 28 | del TWK%2.exe 29 | del TWK%2.obj 30 | del TWK%2.bin 31 | del TWK%2.map 32 | goto Exit 33 | 34 | :SelectType 35 | echo Usage: "makebgi [s|t] clr {version}" 36 | echo Version defaults to BGI v2.0 37 | echo For example: to make the Tweaked-16 color driver (v2.0) enter: "makebgi t 16" 38 | echo for BGI v3.0: "makebgi t 16 3" 39 | 40 | :Exit -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 jharg93 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MAKEFILE.SVG: -------------------------------------------------------------------------------- 1 | ## Makefile for initsvga.c (SuperVGA drivers) 2 | ## Demonstrates use of registerfarbgidriver 3 | PROG = initsvga # Program name to compile 4 | CC = tcc # Command-line compiler (tcc/bcc) 5 | LIB = e:\lang\lib # Library directory 6 | INCLUDE = e:\lang\include # Include directory 7 | MODEL = s # Memory Model 8 | 9 | $(PROG).exe: $(PROG).c svga256f.obj svga16f.obj svga32kf.obj 10 | $(CC) -L$(LIB) -I$(INCLUDE) -m$(MODEL) $(PROG).c \ 11 | svga32kf.obj svga256f.obj svga16f.obj graphics.lib 12 | 13 | svga256f.obj : svga256.bgi 14 | bgiobj /F svga256.bgi svga256f.obj _Svga256_fdriver SVGA256_TEXT 15 | 16 | svga16f.obj : svga16.bgi 17 | bgiobj /F svga16.bgi svga16f.obj _Svga16_fdriver SVGA16_TEXT 18 | 19 | svga64kf.obj : svga64k.bgi 20 | bgiobj /F svga64k.bgi svga64kf.obj _Svga64k_fdriver SVGA64k_TEXT 21 | 22 | svgaTCf.obj : svgaTC.bgi 23 | bgiobj /F svgaTC.bgi svgaTCf.obj _SvgaTC_fdriver SVGATC_TEXT 24 | 25 | svga32kf.obj : svga32k.bgi 26 | bgiobj /F svga32k.bgi svga32kf.obj _Svga32k_fdriver SVGA32k_TEXT 27 | 28 | svgas3f.obj : svgas3.bgi 29 | bgiobj /F svgas3.bgi svgas3f.obj _SvgaS3_fdriver SVGAS3_TEXT 30 |  -------------------------------------------------------------------------------- /NOTES256.TWK: -------------------------------------------------------------------------------- 1 | TweakVGA 256 BGI driver 2 | Version 1.7 3 | August 23, 1994 4 | 5 | Revisions: 6 | 1.7 - August 23, 1994 7 | 1.65 - July 20, 1994 8 | 1.5 - August 28, 1993 9 | 1.4 - May 21, 1993 10 | 1.3 - April 4, 1993 11 | 1.25 - January 28, 1993 12 | 1.2 - June 22, 1992 13 | 14 | This is the newest version of my 256 color tweaked BGI driver. All applicable 15 | functions have been implemented. 16 | 17 | NOTES: The mouse cursor will not work unless the HGXMOUSE TSR is loaded. 18 | 19 | o Greatly improved speed on bar filling (1.0) 20 | 21 | o Getimage/Putimage now work (1.1) 22 | 23 | o Paging is now implemented (1.2) 24 | 25 | Mode Paging # of pages (with 64k..no bank switch) 26 | 320x400 yes 2 27 | 360x480 no 1 28 | 376x564 no 1 29 | 400x564 no 1 30 | 400x600 no 1 31 | 320x240 yes 3 32 | 33 | o Mouse code hooks added (1.25) 34 | 35 | o Fillpattern bug fixed (It was being written backwards - 1.3) 36 | 37 | o Fixed text clipping at right and bottom edges (1.4) 38 | 39 | o Added compile-time support for 8x8, 8x14, or 8x16 bitmap fonts (1.4) 40 | 41 | o Drivers now have compile-time support for BGI version 3.0. 42 | Supports protected mode with Borland Pascal 7.0 (1.5) 43 | 44 | o Integrated support for HGXMOUSE mouse cursor TSR. (1.65) 45 | 46 | o Added 360x350x256 mode (1.7) 47 | 48 |  -------------------------------------------------------------------------------- /ERROR.LOG: -------------------------------------------------------------------------------- 1 | Fill this out if you experience any problems with any of the drivers. 2 | 3 | Video adaptor type:_______________________________________________________ 4 | Memory on video card: ( )256k ( )512k ( )768k ( )1Meg ( )2Meg ( )4Meg 5 | 6 | Video modes with problems (from VGADEMO.EXE or others): 7 | 0 1 2 3 4 5 6 7 8 | Svga16 : 9 | Svga256: 10 | Svga32k: 11 | Svga64k: 12 | SvgaS3 : 13 | SvgaTC : 14 | 15 | Tweaked modes depend on monitor/card combinations, so some modes may be 16 | out of sync with some configurations. 17 | 0 1 2 3 4 5 6 7 18 | Twk16: 19 | Twk256: 20 | 21 | Description of problems: 22 | ____________________________________________________________________________ 23 | ____________________________________________________________________________ 24 | ____________________________________________________________________________ 25 | ____________________________________________________________________________ 26 | ____________________________________________________________________________ 27 | ____________________________________________________________________________ 28 | ____________________________________________________________________________ 29 | ____________________________________________________________________________ 30 | ____________________________________________________________________________ 31 | ____________________________________________________________________________ 32 |  -------------------------------------------------------------------------------- /SVGAUTIL.H: -------------------------------------------------------------------------------- 1 | /************************************************/ 2 | /* */ 3 | /* BGI common defines/utility functions */ 4 | /* Copyright (c) 1994 */ 5 | /* Jordan Hargraphix Software */ 6 | /* */ 7 | /************************************************/ 8 | #ifndef __SVGAUTIL_H__ 9 | #define __SVGAUTIL_H__ 10 | 11 | typedef unsigned char DacPalette16[16][3]; 12 | typedef unsigned char DacPalette256[256][3]; 13 | 14 | #define XNOR_PUT 5 15 | #define NOR_PUT 6 16 | #define NAND_PUT 7 17 | #define TRANS_COPY_PUT 8 /* Doesn't work with 16-color drivers */ 18 | 19 | #pragma pack(1) 20 | typedef struct __bpp24 { 21 | unsigned char bVal; 22 | unsigned char gVal; 23 | unsigned char rVal; 24 | } __bpp24; 25 | 26 | typedef struct __bpp16 { 27 | unsigned int bVal : 5; 28 | unsigned int gVal : 6; 29 | unsigned int rVal : 5; 30 | } __bpp16; 31 | 32 | typedef struct __bpp15 { 33 | unsigned int bVal : 5; 34 | unsigned int gVal : 5; 35 | unsigned int rVal : 5; 36 | } __bpp15; 37 | 38 | typedef union { 39 | struct __bpp24 c24; 40 | struct __bpp16 c16; 41 | struct __bpp15 c15; 42 | unsigned long cval; 43 | } __rColor; 44 | #pragma pack() 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | /* Define enhanced color setting functions */ 51 | long RGB(char,char,char); 52 | long RealDrawColor(long); 53 | long RealFillColor(long); 54 | long RealColor(long); 55 | 56 | /* Define palette functions */ 57 | void getvgapalette16(DacPalette16 *); 58 | void getvgapalette256(DacPalette256 *); 59 | 60 | #ifdef __cplusplus 61 | }; 62 | #endif 63 | 64 | #endif /* __SVGAUTIL_H__ */ 65 | -------------------------------------------------------------------------------- /BGIHDR.H: -------------------------------------------------------------------------------- 1 | #ifndef __BGIHDR_H__ 2 | #define __BGIHDR_H__ 3 | 4 | #define HEADER_SIZE 0xA0 5 | 6 | #define subRev2 1 7 | #define subRev3 1 8 | 9 | typedef unsigned char byte; 10 | 11 | //================================= 12 | class bgiHeader 13 | { 14 | char myName[16]; 15 | unsigned int codeSize; 16 | unsigned char version; 17 | unsigned char revision; 18 | unsigned char subRev; 19 | unsigned char minVersion; 20 | unsigned char minRevision; 21 | unsigned char driverNum; 22 | protected: 23 | public: 24 | bgiHeader(char *drvName,int codeSz,int ver,int rev,int sRev,int minVer, 25 | int minRev); 26 | virtual void writeHeader(FILE *outFile); 27 | void writeDriverName(FILE *outFile); 28 | virtual const char *header() = 0; 29 | virtual int isHeaderValid(const byte *) = 0; 30 | }; 31 | 32 | //================================= 33 | class bgiHeader2 : public bgiHeader { 34 | public: 35 | bgiHeader2(char *drvName,int codeSz); 36 | void writeHeader(FILE *outFile) { bgiHeader::writeHeader(outFile); }; 37 | const char *header() { return ("pk\x8\x8"); }; 38 | virtual int isHeaderValid(const byte *); 39 | }; 40 | 41 | //================================= 42 | class bgiHeader3 : public bgiHeader { 43 | unsigned int dataOfs; 44 | unsigned int dataSize; 45 | public: 46 | bgiHeader3(char *drvName,unsigned int codeSz,unsigned int dataOffset,unsigned int dataSz); 47 | void writeHeader(FILE *outFile); 48 | const char *header() { return ("FBGD\x8\x8\x8\x8"); }; 49 | virtual int isHeaderValid(const byte *); 50 | }; 51 | 52 | #endif /* __BGIHDR_H__ */ 53 |  -------------------------------------------------------------------------------- /SHAREWRE.TXT: -------------------------------------------------------------------------------- 1 | 2 | ABOUT SHAREWARE... 3 | 4 | Shareware (also known as user supported software and other names) is a 5 | concept not understood by everyone. The authors of Shareware retain all 6 | rights to the software under the copyright laws while still allowing 7 | free distribution. This gives the user the chance to freely obtain and 8 | try out software to see if it fits his needs. Shareware should not be 9 | confused with Public Domain software even though they are often obtained 10 | from the same sources. 11 | 12 | If you continue to use Shareware after trying it out, you are expected 13 | to register your use with the author and pay a registration fee. What 14 | you get in return depends on the author, but may include a printed 15 | manual, free updates, telephone support, etc. Only by paying for the 16 | Shareware you use do you enable the Shareware author to continue to 17 | support his software and create new programs. Considering that the 18 | Shareware registration fees are almost always far less than the purchase 19 | price of comparable commercial software it's obvious that Shareware is a 20 | good deal for everyone. 21 | 22 | There are real advantages to you in the Shareware system. You get to 23 | try out software to make sure it is compatible with your hardware and 24 | that it fits your needs before you "buy" it with your registration. 25 | The author saves the expense of advertising, packaging and distribution 26 | and passes the savings on to you. Plus, most Shareware authors are 27 | much more accessible than commercial software sources so that your 28 | questions and suggestions are much more likely to be responded to. 29 | 30 | 31 | Thank you for your support. 32 | -------------------------------------------------------------------------------- /SOURCE/S3CODE.INC: -------------------------------------------------------------------------------- 1 | ;; S3 port numbers 2 | FRGD_MIX EQU 0bae8h 3 | FRGD_COLOR EQU 0a6e8h 4 | MULTIFUNC_CNTL EQU 0bee8h 5 | CUR_Y EQU 082e8h 6 | CUR_X EQU 086e8h 7 | MAJ_AXIS EQU 096e8h 8 | DIAGX_STEP EQU 08ee8h 9 | DIAGY_STEP EQU 08ae8h 10 | ERR_TERM EQU 092e8h 11 | CMD EQU 09ae8h 12 | CMD_REG EQU 09ae8h 13 | GP_STAT EQU 09ae8h 14 | CURWIDTH EQU 096e8h 15 | CURHEIGHT EQU 0bee0h 16 | WRT_MASK EQU 0aae8h 17 | BKGD_COLOR EQU 0a2e8h 18 | BKGD_MIX EQU 0b6e8h 19 | DESTY_AXSTP EQU 08ae8h 20 | DESTX_DIASTP EQU 08ee8h 21 | ERR_TERM EQU 092e8h 22 | MAJ_AXIS_PCNT EQU 096e8h 23 | PIX_TRANS EQU 0e2e8h 24 | COLOR_CMP EQU 0b2e8h 25 | 26 | DataReady EQU 0100h 27 | OneEmpty EQU 080h 28 | TwoEmpty EQU 040h 29 | ThreeEmpty EQU 020h 30 | FourEmpty EQU 010h 31 | FiveEmpty EQU 008h 32 | SixEmpty EQU 004h 33 | SevenEmpty EQU 002h 34 | EightEmpty EQU 001h 35 | CmdRect EQU 04000h 36 | CmdLine EQU 02000h 37 | ByteSwap EQU 01000h 38 | BusSize EQU 0200h 39 | Xmajor EQU 0h 40 | YMajor EQU 40h 41 | XPositive EQU 20h 42 | YPositive EQU 80h 43 | XNegative EQU 0h 44 | YNegative EQU 0h 45 | LPelOff EQU 4 46 | LPelOn EQU 0 47 | MultiPel EQU 2 48 | SinglePel EQU 0 49 | WriteOp EQU 1 50 | ReadOp EQU 0 51 | DrawTo EQU 10h 52 | Pel_Cntl EQU 0a000h 53 | DE_Ones EQU 0 54 | DE_PelPos EQU 040h 55 | DE_CPU EQU 080h 56 | DE_DISPLAY EQU 0c0h 57 | WaitCpu EQU 0100h 58 | 59 | Wait_Till_Fifo MACRO __nempty 60 | LOCAL LL1 61 | mov dx,GP_STAT 62 | LL1: in ax,dx 63 | test ax,__nempty 64 | jne LL1 65 | ENDM 66 | 67 | Wait_For_Data MACRO 68 | LOCAL LL1 69 | mov dx,GP_STAT 70 | LL1: in ax,dx 71 | test ax,DataReady 72 | je LL1 73 | ENDM 74 | 75 | OutCMD MACRO __val 76 | IFNB <__val> 77 | mov ax,__val 78 | ENDIF 79 | mov dx,CMD_REG 80 | out dx,ax 81 | ENDM 82 |  -------------------------------------------------------------------------------- /NOTES16.SVG: -------------------------------------------------------------------------------- 1 | SuperVGA 16 BGI driver 2 | Version 2.2 3 | August 23, 1994 4 | 5 | Revisions: 6 | 2.2 - August 23, 1994 7 | 2.15 - July 20, 1994 8 | 2.1 - March 30, 1994 9 | 2.05 - March 8, 1994 10 | 2.0 - August 28, 1993 11 | 1.7 - May 21, 1993 12 | 1.6 - April 20, 1993 13 | 1.55 - January 28, 1993 14 | 1.5 - June 22, 1992 15 | 16 | This is the latest version of my 16 color BGI driver. All functions have 17 | been implemented (including paging and floodfill), and should work like 18 | the EGAVGA driver. 19 | 20 | o Fixed putimage bug. Now logical operations work the way they 21 | are supposed to. ;-> 22 | 23 | o Added new logical operations to putimage: 24 | XNOR_PUT 25 | NAND_PUT 26 | NOR_PUT 27 | 28 | o Fixed VESA support (1.4) 29 | 30 | o Support for the S3 card (non-native mode) has been added (1.5) 31 | 32 | o Enhanced paging support (1.5) 33 | 34 | Mode Paging? # of pages (with 1M) (with std VGA) 35 | 320x200 yes 32 8 36 | 640x200 yes 16 4 37 | 640x350 yes 8 2 38 | 640x480 yes 4 1 39 | 800x600 yes 4 0 40 | 1024x768 yes 2 0 41 | 42 | o Mouse code hooks added (1.55) 43 | 44 | o New card support added, changed old card support (1.6) 45 | Acumos, Avance Logic 2101, Cirrus 54xx, Compaq, MXIC 68020, NCR, 46 | Primus 2000, Realtek 47 | 48 | o Paging enhanced to work with new cards (1.6) 49 | 50 | o 1280x1024x16 support added (not fully tested) (1.6) 51 | 52 | o Fixed text clipping at right and bottom edges (1.7) 53 | 54 | o Added compile-time support for 8x8, 8x14, or 8x16 bitmap fonts (1.7) 55 | 56 | o Drivers now have compile-time support for BGI version 3.0. 57 | Supports protected mode with Borland Pascal 7.0 (2.0) 58 | 59 | o Fixed bug in Cirrus Logic detect (2.05) 60 | 61 | o Sped up line drawing & bar slightly (2.1) 62 | 63 | o New, improved card detection support (2.1) 64 | Supports IITAGX, UMC, HMC, Weitek cards. 65 | 66 | o Fixed Chips & Technologies detect bug (2.15) 67 | 68 | o Integrated support for HGXMOUSE mouse cursor TSR. (2.15) 69 | 70 | o Fixed IIT AGX bankswitch bug (2.2) 71 |  -------------------------------------------------------------------------------- /NOTES256.SVG: -------------------------------------------------------------------------------- 1 | SuperVGA 256 BGI driver 2 | Version 3.2 3 | August 23, 1994 4 | 5 | Revisions: 6 | 3.2 - August 23, 1994 7 | 3.15 - July 20, 1994 8 | 3.1 - March 30, 1994 9 | 3.05 - March 8, 1994 10 | 3.0 - August 28, 1993 11 | 2.6 - May 21, 1993 12 | 2.5 - April 20, 1993 13 | 2.45 - January 28, 1993 14 | 2.4 - June 12, 1992 15 | 16 | This is the newest version of my SuperVGA 256 BGI driver. I have fixed 17 | several bugs in the previous releases, as well as added several improvements. 18 | 19 | o 1024x768x256 color mode is now supported on Tseng 4000, 20 | Chips&Tech, Trident 8900 and Ahead video cards. 21 | 22 | o Getimage and putimage will work with bitmaps up to the 23 | size of available memory. (> 64k) 24 | 25 | o VESA support has been added. 26 | 27 | o Added setvgapalette256 function. 28 | 29 | o Floodfill is implemented. (still slow!) (2.0) 30 | 31 | o Added new logical operations to putimage (2.25) 32 | XNOR_PUT 33 | NOR_PUT 34 | NAND_PUT 35 | TRANS_COPY_PUT - Treats 0 as transparent (useful for cursors) 36 | 37 | o Logical operations for putimage actually work correctly! ;-> (2.3) 38 | 39 | o Fixed minor line drawing bug (2.31) 40 | 41 | o Support for the S3 card (non-native mode) has been added (2.4) 42 | 43 | o Paging has been implemented for SuperVGA cards that support it (2.4) 44 | (Currently only support Tseng4000, C&T, Paradise and Video7; 45 | ATI and Genoa cards do not support paging above 64k) 46 | 47 | Mode Paging? # of pages (with 1024k) 48 | 320x200 yes 16 49 | 640x400 yes 4 50 | 640x480 yes 3 51 | 800x600 yes 2 52 | 1024x768 no 1 53 | 640x350 yes 4 54 | 1280x1024 no 0 (needs 1.2M) 55 | 56 | o Mouse code hooks added (2.45) 57 | 58 | o New card support added, changed old card support (2.5) 59 | Acumos, Avance Logic 2101, Cirrus 54xx, Compaq, MXIC 68020, NCR, 60 | Primus 2000, Realtek 61 | 62 | o Paging enhanced to work with new cards (2.5) 63 | 64 | o Fixed text clipping at right and bottom edges (2.6) 65 | 66 | o Various speed optimizations (line & solid bar) (2.6) 67 | 68 | o Added compile-time support for 8x8, 8x14, or 8x16 bitmap fonts (2.6) 69 | 70 | o Drivers now have compile-time support for BGI version 3.0. 71 | Supports protected mode with Borland Pascal 7.0 (3.0) 72 | 73 | o Fixed Cirrus Logic detect bug (3.05) 74 | 75 | o New, improved card detection support (3.1) 76 | Supports IITAGX, UMC, HMC, Weitek cards. 77 | 78 | o Fixed Chips & Technologies detect bug (3.15) 79 | 80 | o Integrated support for HGXMOUSE mouse cursor TSR. (3.15) 81 | 82 | o Fixed IIT AGX bankswitch bug (3.2) 83 |  -------------------------------------------------------------------------------- /SVGAUTIL.INC: -------------------------------------------------------------------------------- 1 | const 2 | XNOR_PUT = 5; 3 | NOR_PUT = 6; 4 | NAND_PUT = 7; 5 | TRANS_COPY_PUT = 8; (* Doesn't work on 16-color systems *) 6 | 7 | type DacPalette16 = array[0..15] of array[0..2] of Byte; 8 | type DacPalette256 = array[0..255] of array[0..2] of Byte; 9 | 10 | (* Setvgapalette sets the entire 16 color palette *) 11 | (* PalBuf contains RGB values for all 16 colors *) 12 | (* R,G,B values range from 0 to 63 *) 13 | procedure SetVGAPalette16(PalBuf : DacPalette16); 14 | var 15 | Reg : Registers; 16 | 17 | begin 18 | reg.ax := $1012; 19 | reg.bx := 0; 20 | reg.cx := 16; 21 | reg.es := Seg(PalBuf); 22 | reg.dx := Ofs(PalBuf); 23 | intr($10,reg); 24 | end; 25 | 26 | (* Setvgapalette sets the entire 256 color palette *) 27 | (* PalBuf contains RGB values for all 256 colors *) 28 | (* R,G,B values range from 0 to 63 *) 29 | procedure SetVGAPalette256(PalBuf : DacPalette256); 30 | var 31 | Reg : Registers; 32 | 33 | begin 34 | reg.ax := $1012; 35 | reg.bx := 0; 36 | reg.cx := 256; 37 | reg.es := Seg(PalBuf); 38 | reg.dx := Ofs(PalBuf); 39 | intr($10,reg); 40 | end; 41 | 42 | function RGB(R,G,B : LongInt) : LongInt; 43 | var 44 | MaxC : Longint; 45 | begin 46 | MaxC := GetMaxColor; 47 | 48 | if (MaxC = 65535) then 49 | RGB := (((R SHR 3) AND $1F) SHL 11) OR (((G SHR 2) AND $3F) SHL 5) OR 50 | ((B SHR 3) AND $1F) 51 | else if (MaxC = 32767) then 52 | RGB := (((R SHR 3) AND $1F) SHL 10) OR (((G SHR 3) AND $1F) SHL 5) OR 53 | ((B SHR 3) and $1F) 54 | else if (MaxC = 16777) then 55 | RGB := ((R AND $FF) SHL 16) OR ((G AND $FF) SHL 8) OR (B AND $FF); 56 | end; 57 | 58 | function RealDrawColor(Color : LongInt) : LongInt; 59 | var 60 | MaxC : Longint; 61 | begin 62 | MaxC := GetMaxColor; 63 | 64 | if (MaxC = 65535) then 65 | SetRgbPalette(1024,(Color SHR 11) AND $1F,(Color SHR 5)AND $3F,Color AND $1F) 66 | else if (MaxC = 32767) then 67 | SetRgbPalette(1024,(Color SHR 10) AND $1F,(Color SHR 5)AND $1F,Color AND $1F) 68 | else if (MaxC = 16777) then 69 | SetRgbPalette(1024,(Color SHR 16) AND 255,(Color SHR 8)AND 255,Color AND 255); 70 | RealDrawColor := Color; 71 | end; 72 | 73 | function RealFillColor(Color : LongInt) : LongInt; 74 | var 75 | MaxC : Longint; 76 | begin 77 | MaxC := GetMaxColor; 78 | 79 | if (MaxC = 65535) then 80 | SetRgbPalette(1025,(Color SHR 11) AND $1F,(Color SHR 5)AND $3F,Color AND $1F) 81 | else if (MaxC = 32767) then 82 | SetRgbPalette(1025,(Color SHR 10) AND $1F,(Color SHR 5)AND $1F,Color AND $1F) 83 | else if (MaxC = 16777) then 84 | SetRgbPalette(1025,(Color SHR 16) AND 255,(Color SHR 8)AND 255,Color AND 255); 85 | RealFillColor := Color; 86 | end; 87 | 88 | function RealColor(Color : LongInt) : LongInt; 89 | var 90 | MaxC : Longint; 91 | begin 92 | MaxC := GetMaxColor; 93 | 94 | if (MaxC = 65535) then 95 | SetRgbPalette(1026,(Color SHR 11) AND $1F,(Color SHR 5)AND $3F,Color AND $1F) 96 | else if (MaxC = 32767) then 97 | SetRgbPalette(1026,(Color SHR 10) AND $1F,(Color SHR 5)AND $1F,Color AND $1F) 98 | else if (MaxC = 16777) then 99 | SetRgbPalette(1026,(Color SHR 16) AND 255,(Color SHR 8)AND 255,Color AND 255); 100 | RealColor := Color; 101 | end; 102 |  -------------------------------------------------------------------------------- /NOTES_S3.SVG: -------------------------------------------------------------------------------- 1 | SuperVGA S3 BGI driver 2 | Version 1.6 3 | March 30, 1994 4 | 5 | Revisions: 6 | 1.5 - August 28, 1993 7 | 1.1 - May 20, 1993 8 | 1.05 - January 28, 1993 9 | 1.0 - June 28, 1992 10 | 11 | This is the latest version of my SuperVGA S3 BGI driver. All functions 12 | have been implemented, but there may still be bugs. 13 | 14 | o Apparently there is a problem with using putimage at addresses >64k 15 | (The driver will put up a solid block instead of the image) 16 | 17 | Note: Palette functions, and the mouse cursor will not work with this driver. 18 | Paging is not yet implemented 19 | 20 | Using the driver in the 256 and 16 color modes is similar to using the 21 | standard SuperVGA 256 and 16 color drivers. See the files NOTES[256|16].SVG 22 | 23 | Using the S3 driver in 32768 color mode: 24 | 25 | Implementing the 32768 color driver involved several hacks, as 26 | the BGI interface only supports 8-bit color values, but the driver 27 | needed support for 15-bit color values. The procedures that needed 28 | to be changed were those that accepted color values, (SetColor, 29 | SetFillStyle, SetFillPattern, PutPixel and Floodfill) and those 30 | that return color values (GetColor and GetPixel). 31 | As the HiColor modes do not support palettes, I decided to use 32 | the SetRgbPalette call to set colors, as it accepts values for the 33 | R,G and B components of the color. 34 | 35 | The format of a pixel in the HiColor modes is: 36 | -Byte 1- -Byte 0- 37 | xRRRRRGG GGGBBBBB 38 | 39 | Several new functions are defined to make the color selection easier. 40 | In addition, the macro RGB(rv,gv,bv) has been defined. It packs 41 | the R, G and B values into the format described above and returns the 42 | combined color. 43 | 44 | * RealDrawColor(); - Sets the current drawing color. 45 | Usage: 46 | setcolor(RealDrawColor(RGB(rval,gval,bval)); - HiColor modes 47 | setcolor(RealDrawColor(cval)); - (suggested for any other driver) 48 | 49 | * RealFillColor(); - Sets the current fill color. 50 | Usage: 51 | setfillstyle(fillstyle,RealFillColor(RGB(rval,gval,bval))); 52 | setfillstyle(fillstyle,RealFillColor(cval)); 53 | setfillpattern(fillpat,RealFillColor(RGB(rval,gval,bval))); 54 | setfillpattern(fillpat,RealFillColor(cval)); 55 | 56 | * RealColor(); - For putpixel, sets the color of the pixel 57 | - For floodfill, sets the color of the boundary 58 | putpixel(x,y,RealColor(RGB(rval,gval,bval))); 59 | putpixel(x,y,RealColor(cval)); 60 | floodfill(x,y,RealColor(RGB(rval,gval,bval))); 61 | floodfill(x,y,RealColor(cval)); 62 | 63 | * GetPixel normally only returns an 8-bit value. However, the 64 | value returned from the BGI driver is a 16-bit value in DX (the 65 | BGI kernel loads the value into AX and clears the upper 8 bits), 66 | so to read the value of a pixel: 67 | 68 | In Pascal: 69 | Color := getpixel(x,y); 70 | inline($89/$56/, 12 | lastPort = __port 13 | mov dx,__port 14 | ENDIF 15 | IFDIF <__val>, 16 | mov al,__val 17 | ENDIF 18 | out dx,al 19 | ENDM 20 | 21 | outpwi MACRO __port, __val, __inx 22 | IFDIF <__port>, 23 | lastPort = __port 24 | mov dx,__port 25 | ENDIF 26 | IFDIF <__inx>, 27 | mov al,__inx 28 | ENDIF 29 | IFDIF <__val>, 30 | mov ah,__val 31 | ENDIF 32 | out dx,ax 33 | ENDM 34 | 35 | outpw MACRO __port, __val 36 | IFDIF <__port>, 37 | lastPort = __port 38 | mov dx, __port 39 | ENDIF 40 | IFDIF <__val>, 41 | mov ax, __val 42 | ENDIF 43 | out dx, ax 44 | ENDM 45 | 46 | ;; DX = Port 47 | ;; BH = Index 48 | _wrinx MACRO __val 49 | IFIDN <__val>, 50 | .ERR 51 | %OUT Can't have AL as argument to _wrinx 52 | ENDIF 53 | mov al,bh ;; Port index 54 | out dx,al 55 | inc dx 56 | mov al,__val 57 | out dx,al 58 | dec dx 59 | ENDM 60 | 61 | ;; Wrinx(port,idx,val) : Writes a value to an indexed port 62 | wrinx MACRO __port,__inx,__val 63 | IFDIF <__port>, 64 | lastPort = __port 65 | mov dx,__port 66 | ENDIF 67 | ;; mov ax, ((__val AND 0FFh) SHL 8) OR __inx 68 | ;; out dx,ax 69 | IFIDN <__val>, 70 | push ax 71 | ENDIF 72 | mov al,__inx 73 | out dx,al 74 | inc dx 75 | IFIDN <__val>, 76 | pop ax 77 | ELSE 78 | mov al,__val 79 | ENDIF 80 | out dx,al 81 | dec dx 82 | ENDM 83 | 84 | wrinx2m MACRO __port, __inx, __val 85 | wrinx __port, __inx, (__val shr 8) and 255 86 | wrinx __port, __inx+1, (__val and 255) 87 | ENDM 88 | 89 | ;; Inp(port) : Reads a value from a port 90 | inp MACRO __port 91 | IFDIF <__port>, 92 | lastPort = __port 93 | mov dx,__port 94 | ENDIF 95 | in al,dx 96 | ENDM 97 | 98 | _rdinx MACRO 99 | mov al,bh 100 | out dx,al 101 | inc dx 102 | in al,dx 103 | dec dx 104 | ENDM 105 | 106 | ;; Rdinx(port,idx) : Reads a value from an indexed port 107 | rdinx MACRO __port, __inx 108 | IFDIF <__port>, 109 | lastPort = __port 110 | mov dx,__port 111 | ENDIF 112 | mov al,__inx 113 | out dx,al 114 | inc dx 115 | in al,dx 116 | dec dx 117 | ENDM 118 | 119 | clrinx MACRO __port, __inx, __val 120 | rdinx __port, __inx 121 | and al, (not __val) and 255 122 | wrinx __port, __inx, al 123 | ENDM 124 | 125 | setinx MACRO __port,__inx,__nwv 126 | rdinx __port,__inx 127 | or al,__nwv 128 | wrinx __port,__inx,al 129 | ENDM 130 | 131 | modinx MACRO __port,__inx,__mask,__nwv 132 | IFDIF <__port>, 133 | lastPort = __port 134 | mov dx,__port 135 | ENDIF 136 | push ax 137 | ;; mov ax, ((__nwv AND __mask) SHL 8) OR __inx) 138 | mov ah, __nwv 139 | and ah, __mask 140 | mov al, __inx 141 | out dx,al 142 | inc dx 143 | in al,dx 144 | and al, (not __mask) and 255 145 | or al,ah 146 | out dx,al 147 | dec dx 148 | pop ax 149 | ENDM 150 | 151 | ;; Test to see if an indexed port is active 152 | TestInx2 MACRO __port, __index, __mask 153 | IFDIF <__port>, 154 | lastPort = __port 155 | mov dx,__port 156 | ENDIF 157 | mov bx, ((__index AND 0ffh) SHL 8) OR __mask 158 | call TestIndex2 159 | ENDM 160 | 161 | ;; Test to see if a register is active 162 | tstreg MACRO __port,__mask 163 | IFDIF <__port>, 164 | lastPort = __port 165 | mov dx,__port 166 | ENDIF 167 | mov bl,__mask 168 | call TestPort 169 | ENDM 170 | 171 |  -------------------------------------------------------------------------------- /NOTESTC.SVG: -------------------------------------------------------------------------------- 1 | SuperVGA TrueColor (24-bit) BGI driver 2 | Version 1.7 3 | August 23, 1994 4 | 5 | Revisions: 6 | 1.7 - August 23, 1994 7 | 1.2 - July 20, 1994 8 | 1.1 - May 30, 1994 9 | 1.0 - April 30, 1994 10 | 11 | This is the latest version of my SuperVGA TrueColor BGI driver. All functions 12 | have been implemented, but there may still be bugs. This driver will only 13 | work on a 386 or higher. 14 | 15 | Note: Palette functions, and the mouse cursor will not work with this driver. 16 | The mouse cursor will work if you have the HGXMOUSE TSR loaded. 17 | 18 | Using the HiColor driver: 19 | 20 | Implementing the TrueColor color driver involved several hacks, as 21 | the BGI interface only supports 8-bit color values, but the driver 22 | needed support for 24-bit color values. The procedures that needed 23 | to be changed were those that accepted color values, (SetColor, 24 | SetFillStyle, SetFillPattern, PutPixel and Floodfill) and those 25 | that return color values (GetColor and GetPixel). 26 | As the TrueColor modes do not support palettes, I decided to use 27 | the SetRgbPalette call to set colors, as it accepts values for the 28 | R,G and B components of the color. 29 | 30 | The format of a pixel in the TrueColor modes is: 31 | -Byte 2- -Byte 1- -Byte 0- 32 | RRRRRRRR GGGGGGGG BBBBBBBB 33 | 34 | Several new functions are defined to make the color selection easier. 35 | In addition, the macro RGB(rv,gv,bv) has been defined. It packs 36 | the R, G and B values into the format described above and returns the 37 | combined color. 38 | 39 | * RealDrawColor(); - Sets the current drawing color. 40 | Usage: 41 | setcolor(RealDrawColor(RGB(rval,gval,bval)); - HiColor modes 42 | setcolor(RealDrawColor(cval)); - (suggested for any other driver) 43 | 44 | * RealFillColor(); - Sets the current fill color. 45 | Usage: 46 | setfillstyle(fillstyle,RealFillColor(RGB(rval,gval,bval))); 47 | setfillstyle(fillstyle,RealFillColor(cval)); 48 | setfillpattern(fillpat,RealFillColor(RGB(rval,gval,bval))); 49 | setfillpattern(fillpat,RealFillColor(cval)); 50 | 51 | * RealColor(); - For putpixel, sets the color of the pixel 52 | - For floodfill, sets the color of the boundary 53 | putpixel(x,y,RealColor(RGB(rval,gval,bval))); 54 | putpixel(x,y,RealColor(cval)); 55 | floodfill(x,y,RealColor(RGB(rval,gval,bval))); 56 | floodfill(x,y,RealColor(cval)); 57 | 58 | * RealDrawColor, RealFillColor, and RealColor all use a hacked 59 | interface to setrgbpalette. If you would rather use the call 60 | directly, the format is: 61 | 62 | RealDrawColor: 63 | setrgbpalette(1024,Rval,Gval,Bval); 64 | RealFillColor: 65 | setrgbpalette(1025,Rval,Gval,Bval); 66 | RealColor: 67 | setrgbpalette(1026,Rval,Gval,Bval); 68 | 69 | where Rval, Gval, Bval = 0..255. 70 | 71 | * GetPixel normally only returns an 8-bit value. However, the 72 | value returned from the BGI driver is a 32-bit value in EDX (the 73 | BGI kernel loads the value into AX and clears the upper 8 bits), 74 | so to read the value of a pixel: 75 | 76 | In Pascal: 77 | Color := getpixel(x,y); 78 | inline($89/$56/ debug svga256.bgi 44 | -d180 l 20 45 | 0D74:0180 A0 00 00 00 5C 22 02 00-01 00 07 53 56 47 41 32 ....\".....SVGA2 46 | 0D74:0190 35 36 00 00 00 00 00 00-00 00 00 00 00 00 00 00 56.............. 47 | -a18a 48 | { Note: For the protected mode driver, the offset is 18E } 49 | 0D74:018A db 6,'EGAVGA',0 50 | 0D74:0192 51 | -d180 l 20 52 | 0D74:0180 A0 00 00 00 5C 22 02 00-01 00 06 45 47 41 56 47 ....\".....EGAVG 53 | 0D74:0190 41 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 A............... 54 | -w 55 | -q 56 | 57 | --------------------------------------------------------------------------- 58 | Q: Why do I get an 'invalid device driver file' when I run my program? 59 | 60 | A: You are probably using Turbo/Borland Pascal 7.0 in protected mode 61 | with a BGI v2.0 file. TC++/BC++ and TP/BP in real mode need a 62 | BGI version 2.0 file. In protected mode, BP/TP 7.0 need a BGI 63 | version 3.0 file. BGI v2.0 and BGIv3.0 drivers are not compatible 64 | with each other. The normal v2.0 drivers are located in the main 65 | source directory, the protected mode drivers are in the BGI30 directory. 66 | 67 | --------------------------------------------------------------------------- 68 | Q: Why doesn't imagesize return the correct value? 69 | 70 | A: The imagesize() function doesn't call the BGI drivers to calculate the 71 | size of an image. It also won't return a value >64k. The correct 72 | size calculation for the different drivers is: 73 | 74 | Svga16,Twk16 : imsize = 4+(((long)xwid >> 1)+1)*ywid; 75 | Svga256,Twk256 : imsize = 4+((long)xwid)*ywid; 76 | Svga32k/Svga64k : imsize = 4+((long)xwid << 1)*ywid; 77 | SvgaTC : imsize = 4+((long)xwid << 2)*ywid; 78 | 79 | --------------------------------------------------------------------------- 80 | Q: Why does initgraph return error 246? 81 | 82 | A: The BGI driver returns an 8-bit signed value to the BGI kernel. The 83 | BGI kernel zero extends this value, instead of sign extending it, so 84 | the value it is returning is actually 246 instead of -10, which is 85 | grModeNotSup (mode not supported). This means that your video card 86 | does not support that particular mode. If no extended modes work 87 | on your card, either your card is not supported or it is not getting 88 | detected properly. 89 |  -------------------------------------------------------------------------------- /NOTES32K.SVG: -------------------------------------------------------------------------------- 1 | SuperVGA 32768 BGI driver 2 | Version 1.7 3 | August 23, 1994 4 | 5 | Revisions: 6 | 1.7 - August 23, 1994 7 | 1.65 - July 20, 1994 8 | 1.6 - March 30, 1994 9 | 1.55 - March 8, 1994 10 | 1.5 - August 28, 1993 11 | 1.3 - May 21, 1993 12 | 1.2 - April 20, 1993 13 | 1.15 - January 28, 1993 14 | 1.1 - June 12, 1992 15 | 16 | This is the newest version of my SuperVGA 32768 BGI driver. All functions 17 | have been implemented, but there may still be bugs. 18 | 19 | Note: Palette functions, and the mouse cursor will not work with this driver. 20 | The mouse cursor will work if you have the HGXMOUSE TSR loaded. 21 | 22 | Using the HiColor driver: 23 | 24 | Implementing the 32768 color driver involved several hacks, as 25 | the BGI interface only supports 8-bit color values, but the driver 26 | needed support for 15-bit color values. The procedures that needed 27 | to be changed were those that accepted color values, (SetColor, 28 | SetFillStyle, SetFillPattern, PutPixel and Floodfill) and those 29 | that return color values (GetColor and GetPixel). 30 | As the HiColor modes do not support palettes, I decided to use 31 | the SetRgbPalette call to set colors, as it accepts values for the 32 | R,G and B components of the color. 33 | 34 | The format of a pixel in the HiColor modes is: 35 | -Byte 1- -Byte 0- 36 | xRRRRRGG GGGBBBBB 37 | 38 | Several new functions are defined to make the color selection easier. 39 | In addition, the macro RGB(rv,gv,bv) has been defined. It packs 40 | the R, G and B values into the format described above and returns the 41 | combined color. 42 | 43 | * RealDrawColor(); - Sets the current drawing color. 44 | Usage: 45 | setcolor(RealDrawColor(RGB(rval,gval,bval)); - HiColor modes 46 | setcolor(RealDrawColor(cval)); - (suggested for any other driver) 47 | 48 | * RealFillColor(); - Sets the current fill color. 49 | Usage: 50 | setfillstyle(fillstyle,RealFillColor(RGB(rval,gval,bval))); 51 | setfillstyle(fillstyle,RealFillColor(cval)); 52 | setfillpattern(fillpat,RealFillColor(RGB(rval,gval,bval))); 53 | setfillpattern(fillpat,RealFillColor(cval)); 54 | 55 | * RealColor(); - For putpixel, sets the color of the pixel 56 | - For floodfill, sets the color of the boundary 57 | putpixel(x,y,RealColor(RGB(rval,gval,bval))); 58 | putpixel(x,y,RealColor(cval)); 59 | floodfill(x,y,RealColor(RGB(rval,gval,bval))); 60 | floodfill(x,y,RealColor(cval)); 61 | 62 | * RealDrawColor, RealFillColor, and RealColor all use a hacked 63 | interface to setrgbpalette. If you would rather use the call 64 | directly, the format is: 65 | 66 | RealDrawColor: 67 | setrgbpalette(1024,Rval,Gval,Bval); 68 | RealFillColor: 69 | setrgbpalette(1025,Rval,Gval,Bval); 70 | RealColor: 71 | setrgbpalette(1026,Rval,Gval,Bval); 72 | 73 | where Rval, Gval, Bval = 0..31. 74 | 75 | * GetPixel normally only returns an 8-bit value. However, the 76 | value returned from the BGI driver is a 16-bit value in DX (the 77 | BGI kernel loads the value into AX and clears the upper 8 bits), 78 | so to read the value of a pixel: 79 | 80 | In Pascal: 81 | Color := getpixel(x,y); 82 | inline($89/$56/ 6 | ;; All Rights Reserved 7 | ;; 8 | ;; This is Copyrighted software. 9 | ;; Permission is hereby granted to use this source code for 10 | ;; private use only. It may NOT be distributed without permission 11 | ;; of the author. 12 | ;; 13 | ;; If you have any comments about changes or improvements in this code, 14 | ;; please let me know. 15 | ;; 16 | ;; Revision history: 17 | ;; ----------------- 18 | ;; $Log: C:/svga/mousesrc/rcs/dosmacro.inv $ 19 | ;; 20 | ;; Rev 1.1 15 Aug 1994 23:03:24 JORDAN 21 | ;; 22 | ;; Rev 1.0 15 Aug 1994 22:59:36 JORDAN 23 | ;; Initial revision. 24 | ;; 25 | 26 | ;;=================================================================== 27 | ;; Opens a file 28 | ;; int _open(char *filename, int mode); 29 | ;; 30 | ;; Input: 31 | ;; __filename = ASCIIZ filename 32 | ;; __mode = R/W mode for opening file 33 | ;;=================================================================== 34 | _O_READ EQU 0 35 | _O_WRITE EQU 1 36 | _O_RDWR EQU 2 37 | OpenFile MACRO __filename, __mode 38 | push dx 39 | push ds 40 | mov ax, cs 41 | mov ds, ax 42 | mov ah, 03Dh 43 | mov al, __mode 44 | lea dx, __filename 45 | int 021h 46 | pop ds 47 | pop dx 48 | ENDM 49 | 50 | ;;=================================================================== 51 | ;; int _creat(char *filename, int mode); 52 | ;; Creates a file 53 | ;; 54 | ;; Input: 55 | ;; __filename = ASCIIZ filename 56 | ;; __attrib = Attribute of file 57 | ;;=================================================================== 58 | CreateFile MACRO __filename, __attrib 59 | push dx 60 | push ds 61 | mov ax, cs 62 | mov ds, ax 63 | mov ah, 03Ch 64 | mov cx, __attrib 65 | lea dx, __filename 66 | int 021h 67 | pop ds 68 | pop dx 69 | ENDM 70 | 71 | ;;=================================================================== 72 | ;; int _close(int); 73 | ;; Closes a file 74 | ;; 75 | ;; Input: 76 | ;; __fd = File descriptor 77 | ;;=================================================================== 78 | CloseFile MACRO __fd 79 | push bx 80 | mov ah, 03eh 81 | mov bx, __fd 82 | int 021h 83 | pop bx 84 | ENDM 85 | 86 | ;;=================================================================== 87 | ;; long _lseek(int, long, int); 88 | ;; Seeks in a file 89 | ;; 90 | ;; Input: 91 | ;; __fd = File descriptor 92 | ;; __hi = Upper 16 bits of offset 93 | ;; __lo = Lower 16 bits of offset 94 | ;; __origin = Start location of seek 95 | ;;=================================================================== 96 | _SEEK_SET EQU 0 97 | _SEEK_CUR EQU 1 98 | _SEEK_END EQU 2 99 | SeekFile MACRO __fd, __hi, __lo, __origin 100 | push bx 101 | push cx 102 | push dx 103 | mov ah, 042h 104 | mov al, __origin 105 | mov bx, __fd 106 | mov cx, __hi 107 | mov dx, __lo 108 | int 021h 109 | pop dx 110 | pop cx 111 | pop bx 112 | ENDM 113 | 114 | ;;=================================================================== 115 | ;; int _read(int, char *, int); 116 | ;; reads to a file 117 | ;; 118 | ;; Input: 119 | ;; __fd = File descriptor 120 | ;; __bseg = segment of buffer 121 | ;; __boff = offset of buffer 122 | ;; __nread = number of bytes to read 123 | ;;=================================================================== 124 | ReadFile MACRO __fd, __bseg, __boff, __nread 125 | push bx 126 | push cx 127 | push dx 128 | push ds 129 | mov ax, __bseg 130 | mov ds, ax 131 | mov ah, 03Fh 132 | mov bx, __fd 133 | mov dx, __boff 134 | mov cx, __nread 135 | int 021h 136 | pop ds 137 | pop dx 138 | pop cx 139 | pop bx 140 | ENDM 141 | 142 | ;;=================================================================== 143 | ;; int _write(int, char *, int); 144 | ;; Writes to a file 145 | ;; 146 | ;; Input: 147 | ;; __fd = File descriptor 148 | ;; __bseg = segment of buffer 149 | ;; __boff = offset of buffer 150 | ;; __nwrite = number of bytes to write 151 | ;;=================================================================== 152 | WriteFile MACRO __fd, __bseg, __boff, __nwrite 153 | push bx 154 | push cx 155 | push dx 156 | push ds 157 | mov ax, __bseg 158 | mov ds, ax 159 | mov ah, 040h 160 | mov bx, __fd 161 | mov dx, __boff 162 | mov cx, __nwrite 163 | int 021h 164 | pop ds 165 | pop dx 166 | pop cx 167 | pop bx 168 | ENDM 169 | 170 | ;;=================================================================== 171 | ;; Prints a string 172 | ;; Input: 173 | ;; __msg = Offset of the string 174 | ;;=================================================================== 175 | Print MACRO __msg 176 | lea dx, __msg 177 | mov ah, 9 178 | int 021h 179 | ENDM 180 | 181 | ;;=================================================================== 182 | ;; Print a string pointer 183 | ;; Input: 184 | ;; __msgMem = Pointer to the string 185 | ;;=================================================================== 186 | PrintIndex MACRO __msgMem 187 | mov dx, [__msgMem] 188 | mov ah, 9 189 | int 021h 190 | ENDM 191 | 192 | ;;=================================================================== 193 | ;; Get interrupt vector 194 | ;; Input: 195 | ;; __vectNum = vector number 196 | ;; Returns: 197 | ;; ES:BX = offset of interrupt handler 198 | ;;=================================================================== 199 | GetIntVect MACRO __vectNum 200 | mov ax, 3500h OR __vectNum 201 | int 021h 202 | ENDM 203 | 204 | ;;=================================================================== 205 | ;; Set interrupt vector 206 | ;; Input: 207 | ;; __vectNum = vector number 208 | ;; __seg = segment of handler, OR dword memory location 209 | ;; __ofs = offset of handler , OR null 210 | ;;=================================================================== 211 | SetIntVect MACRO __vectNum, __seg, __ofs 212 | push ds 213 | IFNB <__ofs> 214 | mov ax, __seg 215 | mov ds, ax 216 | lea dx, __ofs 217 | ELSE 218 | mov dx, word ptr __seg 219 | mov ds, word ptr __seg+2 220 | ENDIF 221 | mov ax, 2500h OR __vectNum 222 | int 021h 223 | pop ds 224 | ENDM 225 |  -------------------------------------------------------------------------------- /SOURCE/COMMON.INC: -------------------------------------------------------------------------------- 1 | MaxStack EQU 300 2 | 3 | STRAIGHT EQU 4 4 | DIAGONAL EQU 0 5 | 6 | ;; Mode types for mouse driver 7 | MODE_P8 EQU 0 8 | MODE_P15 EQU 1 9 | MODE_P16 EQU 2 10 | MODE_P24 EQU 3 11 | MODE_PL4 EQU 4 12 | MODE_PL8 EQU 5 13 | MODE_TEXT EQU 6 14 | MODE_TWKTEXT EQU 7 15 | 16 | HAVE_VESA EQU 00000001b 17 | SLOW_LOGICAL EQU 00000010b 18 | 19 | ;; _SetFlag Sets a bit in a byte flag 20 | _SetFlag MACRO __flag,__val 21 | or byte ptr [__flag], __val 22 | ENDM 23 | 24 | ;; _ClrFlag Clears a bit in a byte flag 25 | _ClrFlag MACRO __flag, __val 26 | and byte ptr [__flag], not __val 27 | ENDM 28 | 29 | ;; _TestFlag Tests a bit in a byte flag 30 | _TestFlag MACRO __flag,__val 31 | test byte ptr [__flag], __val 32 | ENDM 33 | 34 | ;; LoadDataSeg - Load a segment with the value of the data segment 35 | ;; DS = CS for BGI v2.0 code 36 | LoadDataSeg MACRO __segment 37 | IF BGIVERSION LT 3 38 | push cs 39 | pop __segment 40 | ELSE 41 | mov __segment,cs:[alias] 42 | ENDIF 43 | ENDM 44 | 45 | ;;====================================================================== 46 | ;; Entry Header for BGI v3.0 47 | ;;====================================================================== 48 | BGI30Entry MACRO ;; BGI v3.0 entry code 49 | BgiEntry proc far 50 | push ds 51 | mov ds,cs:[alias] 52 | cld 53 | push bp 54 | call word ptr [DDOVEC+si] 55 | pop bp 56 | pop ds 57 | ret 58 | BgiEntry endp 59 | verID db BGIVERSION 60 | ALIAS dw 0 61 | ENDM 62 | 63 | ;;====================================================================== 64 | ;; Entry Header for BGI v2.0 65 | ;;====================================================================== 66 | BGI20Entry MACRO ;; BGI v2.0 entry code 67 | BgiEntry proc far 68 | push ds 69 | push cs 70 | pop ds 71 | cld 72 | push bp 73 | call word ptr [si+DDOVEC] 74 | pop bp 75 | pop ds 76 | ret 77 | BgiEntry endp 78 | db 'CB' 79 | db 0 80 | verID db BGIVERSION 81 | ENDM 82 | 83 | ;; Wait for Display Enable bit to clear 84 | WaitForEnable MACRO 85 | local _waitDE 86 | mov dx,03dah 87 | _waitDE: in al,dx 88 | test al,1 89 | jnz _waitDE 90 | ENDM 91 | 92 | ;; Wait for Vertical Retrace bit to clear 93 | WaitForRetrace MACRO 94 | local _waitVRz 95 | local _waitVRnz 96 | mov dx,03dah 97 | _waitVRnz: in al,dx 98 | test al,8 99 | jnz _waitVRnz 100 | _waitVRz: in al,dx 101 | test al,8 102 | jz _waitVRz 103 | ENDM 104 | 105 | ;; Enable HGXMOUSE mouse support 106 | Enable_Mouse MACRO modetype 107 | mov si, [xsiz] 108 | mov di, [ysiz] 109 | inc di 110 | mov dx, [xbytes] 111 | mov bl, modetype 112 | mov ax, 4500h 113 | int 033h 114 | ENDM 115 | 116 | ;; Disable mouse support 117 | Disable_Mouse MACRO 118 | mov ax, 4501h 119 | int 033h 120 | ENDM 121 | 122 | ;; Set card type macro 123 | SetCardType MACRO __card 124 | mov CurrVidModes, offset &__card&Modes 125 | ENDM 126 | 127 | ;; Set chip/bankswitch macro 128 | SetChipType MACRO __chip 129 | mov BankAdr, offset $&__chip& 130 | ENDM 131 | 132 | ;; Set display start macro 133 | SetPageType MACRO __chip 134 | mov PageAdr, offset $&__chip&_page 135 | ENDM 136 | 137 | ;; Clears a mode from the mode table 138 | ClearMode MACRO __clrmode, __modes, __idx 139 | IF BGIVERSION GE 1 140 | IFDIF <__idx>, 141 | mov word ptr [__modes + __idx*4], 0 142 | mov word ptr [__modes + __idx*4 + 2], 0 143 | ELSE 144 | shl si, 2 145 | mov word ptr [si + __modes], 0 146 | mov word ptr [si + __modes + 2], 0 147 | ENDIF 148 | ENDIF 149 | ENDM 150 | 151 | ;; Sets the bytes per line value for a mode 152 | SetBytesPerLine MACRO __clrmode, __idx, __value 153 | IF BGIVERSION GE 1 154 | IF COLORMODE EQ __clrmode 155 | IFDIF <__idx>, 156 | mov [BytesPerLine+__idx*2], __value 157 | ELSE 158 | shl si, 1 159 | mov [BytesPerLine+si], __value 160 | ENDIF 161 | ENDIF 162 | ENDIF 163 | ENDM 164 | 165 | ;; Loads the text video name (svga or vesa) 166 | LoadModeName MACRO 167 | local @noHaveVesa 168 | mov bx, ModeNameTable[si] 169 | IF USEVESA EQ 1 170 | _TestFlag cardFlags, HAVE_VESA 171 | jz @noHaveVesa 172 | mov bx, ModeVNameTable[si] 173 | @noHaveVesa: 174 | ENDIF 175 | ENDM 176 | 177 | ;; Loads the video mode table (svga or vesa) 178 | LoadVesaModeTable MACRO 179 | local @noHaveVesa 180 | IF USEVESA EQ 1 181 | _TestFlag cardFlags, HAVE_VESA 182 | jz @noHaveVesa 183 | mov CurrVidModes,offset VesaModes 184 | mov BankAdr,offset $vesa 185 | mov PageAdr,offset $vesa_page 186 | @noHaveVesa: 187 | ENDIF 188 | ENDM 189 | 190 | ;; Adds the segment increment value to a segment 191 | IncrSegment MACRO __segment 192 | LOCAL @endIncr 193 | ;; Add increment to segment 194 | mov ax, __segment 195 | add ax, SelectorInc 196 | mov __segment, ax 197 | @endIncr: 198 | ENDM 199 | 200 | TestXBank MACRO __reg, __addr 201 | local @noCross 202 | cmp __reg, __addr 203 | jnz @noCross 204 | inc dl 205 | call newbank 206 | dec dl 207 | @noCross: 208 | ENDM 209 | 210 | ;; Stack structure for PUSHA instruction 211 | PushaStruc struc 212 | RealDI DW 0 213 | RealSI DW 0 214 | RealBP DW 0 215 | RealXX DW 0 216 | RealBX DW 0 217 | RealDX DW 0 218 | RealCX DW 0 219 | RealAX DW 0 220 | PushaStruc ends 221 | 222 | ;; Structure for a DPMI simulate real mode interrupt call 223 | SimIntStruc struc 224 | RealEDI DD 0 225 | RealESI DD 0 226 | RealEBP DD 0 227 | RealESP DD 0 228 | RealEBX DD 0 229 | RealEDX DD 0 230 | RealECX DD 0 231 | RealEAX DD 0 232 | RealFlags DW 0 233 | RealES DW 0 234 | RealDS DW 0 235 | RealFS DW 0 236 | RealGS DW 0 237 | RealIP DW 0 238 | RealCS DW 0 239 | RealSP DW 0 240 | RealSS DW 0 241 | SimIntStruc ends 242 | 243 | ;; BGI Device Information Table 244 | Status struc 245 | stat db 0 ;; Status code 246 | devtyp db 0 ;; Device type - always 0 for graphics adapters 247 | xres dw ? ;; Device x-resoultion 248 | yres dw ? ;; Device y-resolution 249 | xefres dw ? ;; Device effective x-resolution (usually the same as xres) 250 | yefres dw ? ;; Device effective y-resolution (usually the same as yres) 251 | xinch dw 9000 ;; Device width in inches 252 | yinch dw 7000 ;; Device height in inches 253 | aspec dw ? ;; Device aspect ratio 254 | db 08h ;; Text width in pixels 255 | db TEXTBYTES ;; Text height in pixels 256 | db 90h ;; ??? I don't know what these are 257 | db 90h ;; ??? 258 | Status ends 259 | 260 | ;; Include port macros 261 | INCLUDE macros.inc 262 |  -------------------------------------------------------------------------------- /INITSVGA.PAS: -------------------------------------------------------------------------------- 1 | { Sample program that initializes the SuperVGA driver} 2 | Program Test256; 3 | 4 | Uses Graph,Crt,Dos; 5 | 6 | {$i svga16.inc} 7 | {$i svga256.inc} 8 | {$i svga32k.inc} 9 | {$i svga64k.inc} 10 | {$i svgatc.inc} 11 | {$i svgas3.inc} 12 | {$i twk16.inc} 13 | {$i twk256.inc} 14 | {$i svgautil.inc} 15 | 16 | (* Uncomment this if you link in the drivers *) 17 | (* 18 | procedure Svga16_driver; external; 19 | { $L svga16.obj } 20 | 21 | procedure Svga256_driver; external; 22 | { $L svga256.obj } 23 | 24 | procedure Twk256_driver; external; 25 | { $L twk256.obj } 26 | 27 | procedure Twk16_driver; external; 28 | { $L twk16.obj } 29 | 30 | procedure Svga32k_driver; external; 31 | { $L svga32k.obj } 32 | 33 | procedure Svga64k_driver; external; 34 | { $L svga64k.obj } 35 | 36 | procedure SvgaTC_driver; external; 37 | { $L svgatc.obj } 38 | 39 | procedure SvgaS3_driver; external; 40 | { $L svgas3.obj } 41 | *) 42 | 43 | var 44 | GraphMode, GraphDriver, GrErr : integer; 45 | Ky : Char; 46 | Drv : Integer; 47 | 48 | function WhitePixel : Word; 49 | begin 50 | if (GetMaxColor > 256) then 51 | WhitePixel := 32767 52 | else 53 | WhitePixel := 15; 54 | end; 55 | 56 | {$F+} 57 | function DetectVGA256 : Integer; 58 | var Vid : Integer; 59 | 60 | begin 61 | Writeln('Which video mode would you like to use?'); 62 | Writeln(' 0) 320x200x256'); 63 | Writeln(' 1) 640x400x256'); 64 | Writeln(' 2) 640x480x256'); 65 | Writeln(' 3) 800x600x256'); 66 | Writeln(' 4) 1024x768x256'); 67 | Writeln(' 5) 640x350x256'); 68 | Writeln(' 6) 1280x1024x256'); 69 | Write('> '); 70 | Readln(Vid); 71 | DetectVGA256 := Vid; 72 | end; 73 | 74 | function DetectS3 : Integer; 75 | var Vid : Integer; 76 | 77 | begin 78 | Writeln('Which video mode would you like to use?'); 79 | Writeln(' 0) 640x480x256'); 80 | Writeln(' 1) 800x600x256'); 81 | Writeln(' 2) 1024x768x256'); 82 | Writeln(' 3) 800x600x16'); 83 | Writeln(' 4) 1024x768x16'); 84 | Writeln(' 5) 1280x960x16'); 85 | Writeln(' 6) 1280x1024x16'); 86 | Writeln(' 7) 640x480x32768'); 87 | Write('> '); 88 | Readln(Vid); 89 | DetectS3 := Vid; 90 | end; 91 | 92 | function DetectVGATC : Integer; 93 | var Vid : Integer; 94 | 95 | begin 96 | Writeln('Which video mode would you like to use?'); 97 | Writeln(' 0) 320x200x24-bit'); 98 | Writeln(' 1) 640x350x24-bit'); 99 | Writeln(' 2) 640x400x24-bit'); 100 | Writeln(' 3) 640x480x24-bit'); 101 | Writeln(' 4) 800x600x24-bit'); 102 | Writeln(' 5) 1024x768x24-bit'); 103 | Writeln(' 6) 1280x1024x24-bit'); 104 | Write('> '); 105 | Readln(Vid); 106 | DetectVGATC := Vid; 107 | end; 108 | 109 | function DetectVGA64k : Integer; 110 | var Vid : Integer; 111 | 112 | begin 113 | Writeln('Which video mode would you like to use?'); 114 | Writeln(' 0) 320x200x65536'); 115 | Writeln(' 1) 640x350x65536'); 116 | Writeln(' 2) 640x400x65536'); 117 | Writeln(' 3) 640x480x65536'); 118 | Writeln(' 4) 800x600x65536'); 119 | Writeln(' 5) 1024x768x65536'); 120 | Writeln(' 6) 1280x1024x65536'); 121 | Write('> '); 122 | Readln(Vid); 123 | DetectVGA64k := Vid; 124 | end; 125 | 126 | function DetectVGA32k : Integer; 127 | var Vid : Integer; 128 | 129 | begin 130 | Writeln('Which video mode would you like to use?'); 131 | Writeln(' 0) 320x200x32768'); 132 | Writeln(' 1) 640x350x32768'); 133 | Writeln(' 2) 640x400x32768'); 134 | Writeln(' 3) 640x480x32768'); 135 | Writeln(' 4) 800x600x32768'); 136 | Writeln(' 5) 1024x768x32768'); 137 | Writeln(' 6) 1280x1024x32768'); 138 | Write('> '); 139 | Readln(Vid); 140 | DetectVGA32k := Vid; 141 | end; 142 | 143 | function DetectVGA16 : Integer; 144 | var Vid : Integer; 145 | 146 | begin 147 | Writeln('Which video mode would you like to use? '); 148 | Writeln(' 0) 320x200x16'); 149 | Writeln(' 1) 640x200x16'); 150 | Writeln(' 2) 640x350x16'); 151 | Writeln(' 3) 640x480x256'); 152 | Writeln(' 4) 800x600x16'); 153 | Writeln(' 5) 1024x768x16'); 154 | Writeln(' 6) 1280x1024x16'); 155 | Writeln('>'); 156 | Readln(Vid); 157 | DetectVGA16 := Vid; 158 | end; 159 | 160 | function DetectTwk256 : Integer; 161 | var Vid : Integer; 162 | 163 | begin 164 | Writeln('Which video mode would you like to use?'); 165 | Writeln(' 0) 320x400x256'); 166 | Writeln(' 1) 320x480x256'); 167 | Writeln(' 2) 360x480x256'); 168 | Writeln(' 3) 376x564x256'); 169 | Writeln(' 4) 400x564x256'); 170 | Writeln(' 5) 400x600x256'); 171 | Writeln(' 6) 320x240x256'); 172 | Write('> '); 173 | Readln(Vid); 174 | DetectTwk256 := Vid; 175 | end; 176 | 177 | function DetectTwk16 : Integer; 178 | var Vid : Integer; 179 | 180 | begin 181 | Writeln('Which video mode would you like to use? '); 182 | Writeln(' 0) 704x528x16'); 183 | Writeln(' 1) 720x540x16'); 184 | Writeln(' 2) 736x552x16'); 185 | Writeln(' 3) 752x564x256'); 186 | Writeln(' 4) 768x576x16'); 187 | Writeln(' 5) 784x588x16'); 188 | Writeln(' 6) 800x600x16'); 189 | Writeln('>'); 190 | Readln(Vid); 191 | DetectTwk16 := Vid; 192 | end; 193 | {$F-} 194 | 195 | begin 196 | Writeln('Which driver would you like to use?'); 197 | Writeln(' 0) Svga16'); 198 | Writeln(' 1) Svga256'); 199 | Writeln(' 2) Svga32k'); 200 | Writeln(' 3) Svga64k'); 201 | Writeln(' 4) SvgaTC'); 202 | Writeln(' 5) SvgaS3'); 203 | Writeln(' 6) Tweak256'); 204 | Writeln(' 7) Tweak16'); 205 | Write('>'); 206 | Readln(Drv); 207 | if (Drv = 0) then 208 | GraphDriver := InstallUserDriver('SVGA16',@DetectVGA16) 209 | else if (Drv = 1) then 210 | GraphDriver := InstallUserDriver('SVGA256',@DetectVGA256) 211 | else if (Drv = 2) then 212 | GraphDriver := InstallUserDriver('Svga32k',@DetectVGA32k) 213 | else if (Drv = 3) then 214 | GraphDriver := InstallUserDriver('Svga64k',@DetectVGA64k) 215 | else if (Drv = 4) then 216 | GraphDriver := InstallUserDriver('SvgaTC',@DetectVGATC) 217 | else if (Drv = 5) then 218 | GraphDriver := InstallUserDriver('SvgaS3',@DetectS3) 219 | else if (Drv = 6) then 220 | GraphDriver := InstallUserDriver('Twk256',@DetectTwk256) 221 | else if (Drv = 7) then 222 | GraphDriver := InstallUserDriver('Twk16',@DetectTwk16); 223 | GraphDriver := Detect; 224 | InitGraph(GraphDriver,GraphMode,''); 225 | GrErr := GraphResult; { preserve error return } 226 | if GrErr AND $80 = $80 then 227 | GrErr := GrErr OR $ff00; 228 | if GrErr <> grOK then { error? } 229 | begin 230 | Writeln('Graphics error: ', GraphErrorMsg(GrErr)); 231 | Halt(1); 232 | end; 233 | 234 | setcolor(RealDrawColor(WhitePixel)); 235 | line(0,0,GetMaxX,GetMaxY); 236 | line(0,GetMaxY,GetMaxX,0); 237 | Ky := ReadKey; 238 | CloseGraph; 239 | end. 240 |  -------------------------------------------------------------------------------- /INITSVGA.C: -------------------------------------------------------------------------------- 1 | /* Sample program that initializes the SuperVGA driver */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "svgautil.h" 8 | #include "svga16.h" 9 | #include "twk16.h" 10 | #include "twk256.h" 11 | #include "svga256.h" 12 | #include "svga32k.h" 13 | #include "svga64k.h" 14 | #include "svgatc.h" 15 | #include "svgas3.h" 16 | 17 | /* Returns the color for white */ 18 | long WhitePixel() 19 | { 20 | switch(getmaxcolor()) { 21 | case 32768: return 0x7fffL; 22 | case 65535: return 0xffffL; 23 | case 16777: return 0xffffffL; 24 | default : return 15; 25 | }; 26 | } 27 | 28 | int huge DetectVGA256() 29 | { 30 | int Vid; 31 | 32 | printf("Which video mode would you like to use? \n"); 33 | printf(" 0) 320x200x256\n"); 34 | printf(" 1) 640x400x256\n"); 35 | printf(" 2) 640x480x256\n"); 36 | printf(" 3) 800x600x256\n"); 37 | printf(" 4) 1024x768x256\n"); 38 | printf(" 5) 640x480x256\n"); 39 | printf(" 6) 1280x1024x256\n"); 40 | printf("\n> "); 41 | scanf("%d",&Vid); 42 | return Vid; 43 | } 44 | 45 | int huge DetectS3() 46 | { 47 | int Vid; 48 | 49 | printf("Which video mode would you like to use?\n"); 50 | printf(" 0) 640x480x256\n"); 51 | printf(" 1) 800x600x256\n"); 52 | printf(" 2) 1024x768x256\n"); 53 | printf(" 3) 800x600x16\n"); 54 | printf(" 4) 1024x768x16\n"); 55 | printf(" 5) 1280x960x16\n"); 56 | printf(" 6) 1280x1024x16\n"); 57 | printf(" 7) 640x480x32768\n"); 58 | printf("> "); 59 | scanf("%d",&Vid); 60 | return Vid; 61 | } 62 | int huge DetectVGA64k() 63 | { 64 | int Vid; 65 | 66 | printf("Which video mode would you like to use? \n"); 67 | printf(" 0) 320x200x65536\n"); 68 | printf(" 1) 640x350x65536\n"); 69 | printf(" 2) 640x400x65536\n"); 70 | printf(" 3) 640x480x65536\n"); 71 | printf(" 4) 800x600x65536\n"); 72 | printf(" 5) 1024x768x65536\n"); 73 | printf(" 6) 1280x1024x65536\n"); 74 | printf("\n> "); 75 | scanf("%d",&Vid); 76 | return Vid; 77 | } 78 | 79 | int huge DetectVGA24bit() 80 | { 81 | int Vid; 82 | 83 | printf("Which video mode would you like to use? \n"); 84 | printf(" 0) 320x200x24-bit\n"); 85 | printf(" 1) 640x350x24-bit\n"); 86 | printf(" 2) 640x400x24-bit\n"); 87 | printf(" 3) 640x480x24-bit\n"); 88 | printf(" 4) 800x600x24-bit\n"); 89 | printf(" 5) 1024x768x24-bit\n"); 90 | printf(" 6) 1280x1024x24-bit\n"); 91 | printf("\n> "); 92 | scanf("%d",&Vid); 93 | return Vid; 94 | } 95 | 96 | int huge DetectVGA32k() 97 | { 98 | int Vid; 99 | 100 | printf("Which video mode would you like to use? \n"); 101 | printf(" 0) 320x200x32768\n"); 102 | printf(" 1) 640x350x32768\n"); 103 | printf(" 2) 640x400x32768\n"); 104 | printf(" 3) 640x480x32768\n"); 105 | printf(" 4) 800x600x32768\n"); 106 | printf(" 5) 1024x768x32768\n"); 107 | printf(" 6) 1280x1024x32768\n"); 108 | printf("\n> "); 109 | scanf("%d",&Vid); 110 | return Vid; 111 | } 112 | 113 | int huge DetectVGA16() 114 | { 115 | int Vid; 116 | 117 | printf("Which video mode would you like to use? \n"); 118 | printf(" 0) 320x200x16\n"); 119 | printf(" 1) 640x200x16\n"); 120 | printf(" 2) 640x350x16\n"); 121 | printf(" 3) 640x480x256\n"); 122 | printf(" 4) 800x600x16\n"); 123 | printf(" 5) 1024x768x16\n"); 124 | printf(" 6) 1280x1024x16\n"); 125 | printf("\n> "); 126 | scanf("%d",&Vid); 127 | return Vid; 128 | } 129 | 130 | int huge DetectTwk16() 131 | { 132 | int Vid; 133 | 134 | printf("Which video mode would you like to use? \n"); 135 | printf(" 0) 704x528x16\n"); 136 | printf(" 1) 720x540x16\n"); 137 | printf(" 2) 736x552x16\n"); 138 | printf(" 3) 752x564x16\n"); 139 | printf(" 4) 768x576x16\n"); 140 | printf(" 5) 784x588x16\n"); 141 | printf(" 6) 800x600x16\n"); 142 | printf("\n> "); 143 | scanf("%d",&Vid); 144 | return Vid; 145 | }; 146 | 147 | int huge DetectTwk256() 148 | { 149 | int Vid; 150 | 151 | printf("Which video mode would you like to use? \n"); 152 | printf(" 0) 320x400x256\n"); 153 | printf(" 1) 320x480x256\n"); 154 | printf(" 2) 360x480x256\n"); 155 | printf(" 3) 376x564x256\n"); 156 | printf(" 4) 400x564x256\n"); 157 | printf(" 5) 400x600x256\n"); 158 | printf(" 6) 320x240x256\n"); 159 | printf("\n> "); 160 | scanf("%d",&Vid); 161 | return Vid; 162 | }; 163 | 164 | void main() 165 | { 166 | int Gd = DETECT, Gm; 167 | int Drv; 168 | char GrErr; 169 | 170 | /* Find out which driver the user wants */ 171 | printf("Which driver would you like to use?\n"); 172 | printf(" 0) Svga16\n"); 173 | printf(" 1) Svga256\n"); 174 | printf(" 2) Svga32k\n"); 175 | printf(" 3) Svga64k\n"); 176 | printf(" 4) SvgaTC\n"); 177 | printf(" 5) SvgaS3\n"); 178 | printf(" 6) Tweak256\n"); 179 | printf(" 7) Tweak16\n"); 180 | printf("\n> "); 181 | scanf("%d",&Drv); 182 | switch(Drv) 183 | { 184 | case 0: installuserdriver("Svga16",DetectVGA16); 185 | /* If driver is linked with file, remove comments */ 186 | /* registerfarbgidriver(Svga16_fdriver); */ 187 | break; 188 | 189 | case 1: installuserdriver("Svga256",DetectVGA256); 190 | /* If driver is linked with file, remove comments */ 191 | /* registerfarbgidriver(Svga256_fdriver); */ 192 | break; 193 | 194 | case 2: installuserdriver("Svga32k",DetectVGA32k); 195 | /* If driver is linked with file, remove comments */ 196 | /* registerfarbgidriver(Svga32k_fdriver); */ 197 | break; 198 | 199 | case 3: installuserdriver("Svga64k",DetectVGA64k); 200 | /* If driver is linked with file, remove comments */ 201 | /* registerfarbgidriver(Svga64k_fdriver); */ 202 | break; 203 | 204 | case 4: installuserdriver("SvgaTC",DetectVGA24bit); 205 | /* If driver is linked with file, remove comments */ 206 | /* registerfarbgidriver(SvgaTC_fdriver); */ 207 | break; 208 | 209 | case 5: installuserdriver("SvgaS3",DetectVGAS3); 210 | /* If driver is linked with file, remove comments */ 211 | /* registerfarbgidriver(SvgaS3_fdriver); */ 212 | break; 213 | 214 | case 6: installuserdriver("Twk16",DetectTwk16); 215 | /* If driver is linked with file, remove comments */ 216 | /* registerfarbgidriver(Twk16_fdriver); */ 217 | break; 218 | 219 | case 7: installuserdriver("Twk256",DetectTwk256); 220 | /* If driver is linked with file, remove comments */ 221 | /* registerfarbgidriver(Twk256_fdriver); */ 222 | break; 223 | } 224 | initgraph(&Gd,&Gm,""); 225 | 226 | /* Test if mode was initialized successfully */ 227 | GrErr = graphresult(); 228 | if (GrErr != grOk) { 229 | printf("Graphics error: %s\n",grapherrormsg(GrErr)); 230 | exit(1); 231 | } 232 | 233 | /* Draw an 'X' on the screen */ 234 | setcolor(RealDrawColor(WhitePixel())); 235 | line(0,0,getmaxx(),getmaxy()); 236 | line(0,getmaxy(),getmaxx(),0); 237 | getch(); 238 | closegraph(); 239 | } 240 |  -------------------------------------------------------------------------------- /SVGAUTIL.C: -------------------------------------------------------------------------------- 1 | /************************************************/ 2 | /* */ 3 | /* SuperVGA utility routines */ 4 | /* Copyright (c) 1991 */ 5 | /* Jordan Hargraphix Software */ 6 | /* */ 7 | /************************************************/ 8 | 9 | #include 10 | #include 11 | #include "svgautil.h" 12 | #include "svga16.h" 13 | #include "svga256.h" 14 | #include "svga32k.h" 15 | #include "svga64k.h" 16 | #include "svgatc.h" 17 | #include "svgas3.h" 18 | #include "twk16.h" 19 | #include "twk256.h" 20 | 21 | /************************************************************************/ 22 | /* */ 23 | /* Enhanced color setting functions */ 24 | /* */ 25 | /* These functions are used to set the colors for the 32k/64k/TrueColor */ 26 | /* modes, as the BGI kernel can only handle 8-bit color values. */ 27 | /* */ 28 | /************************************************************************/ 29 | 30 | /********************************************************/ 31 | /* long RGB(char rVal, char gVal, char bVal); */ 32 | /* */ 33 | /* Purpose: Returns the color value for a R,G,B triple */ 34 | /* based on the current graphics mode. */ 35 | /* */ 36 | /* Input: */ 37 | /* char rVal - Red value [0..255] */ 38 | /* char gVal - Green value [0..255] */ 39 | /* char bVal - Blue value [0..255] */ 40 | /* */ 41 | /* Returns: */ 42 | /* long - Color value for this mode. */ 43 | /* */ 44 | /********************************************************/ 45 | long RGB(char rVal, char gVal, char bVal) 46 | { 47 | __rColor xColor; 48 | 49 | switch(getmaxcolor()) { 50 | case 32767: 51 | xColor.c15.rVal = (rVal >> 3) & 0x1F; 52 | xColor.c15.gVal = (gVal >> 3) & 0x1F; 53 | xColor.c15.bVal = (bVal >> 3) & 0x1F; 54 | break; 55 | case 65535: 56 | xColor.c16.rVal = (rVal >> 3) & 0x1F; 57 | xColor.c16.gVal = (gVal >> 2) & 0x1F; 58 | xColor.c16.bVal = (bVal >> 3) & 0x1F; 59 | break; 60 | case 16777: 61 | xColor.c24.rVal = rVal; 62 | xColor.c24.gVal = gVal; 63 | xColor.c24.bVal = bVal; 64 | break; 65 | } 66 | return (xColor.cval); 67 | } 68 | 69 | /****************************************************************/ 70 | /* long RealDrawColor(long color); */ 71 | /* */ 72 | /* Purpose: Sets the current drawing color for HC/TC modes. */ 73 | /* Used for 'setcolor' */ 74 | /* */ 75 | /* Input: */ 76 | /* long color - Color value */ 77 | /* */ 78 | /* Returns: */ 79 | /* long - Color value */ 80 | /* */ 81 | /****************************************************************/ 82 | long RealDrawColor(long color) 83 | { 84 | __rColor xColor; 85 | 86 | xColor.cval = color; 87 | /* Do color set hacks for hicolor/truecolor modes */ 88 | switch(getmaxcolor()) { 89 | case 32767: 90 | setrgbpalette(1024,xColor.c15.rVal,xColor.c15.gVal,xColor.c15.bVal); 91 | break; 92 | case 65535: 93 | setrgbpalette(1024,xColor.c16.rVal,xColor.c16.gVal,xColor.c16.bVal); 94 | break; 95 | case 16777: 96 | setrgbpalette(1024,xColor.c24.rVal,xColor.c24.gVal,xColor.c24.bVal); 97 | break; 98 | }; 99 | return color; 100 | } 101 | 102 | /****************************************************************/ 103 | /* long RealFillColor(long color); */ 104 | /* */ 105 | /* Purpose: Sets the current fill color for HC/TC modes. */ 106 | /* Used for 'setfillstyle' and 'setfillpattern' */ 107 | /* */ 108 | /* Input: */ 109 | /* long color - Color value */ 110 | /* */ 111 | /* Returns: */ 112 | /* long - Color value */ 113 | /* */ 114 | /****************************************************************/ 115 | long RealFillColor(long color) 116 | { 117 | __rColor xColor; 118 | 119 | xColor.cval = color; 120 | /* Do color set hacks for hicolor/truecolor modes */ 121 | switch(getmaxcolor()) { 122 | case 32767: 123 | setrgbpalette(1025,xColor.c15.rVal,xColor.c15.gVal,xColor.c15.bVal); 124 | break; 125 | case 65535: 126 | setrgbpalette(1025,xColor.c16.rVal,xColor.c16.gVal,xColor.c16.bVal); 127 | break; 128 | case 16777: 129 | setrgbpalette(1025,xColor.c24.rVal,xColor.c24.gVal,xColor.c24.bVal); 130 | break; 131 | }; 132 | return color; 133 | } 134 | 135 | /****************************************************************/ 136 | /* long RealColor(long color); */ 137 | /* */ 138 | /* Purpose: Sets the current color for HC/TC modes. */ 139 | /* Used for 'putpixel' and 'floodfill' */ 140 | /* */ 141 | /* Input: */ 142 | /* long color - Color value */ 143 | /* */ 144 | /* Returns: */ 145 | /* long - Color value */ 146 | /* */ 147 | /****************************************************************/ 148 | long RealColor(long color) 149 | { 150 | __rColor xColor; 151 | 152 | xColor.cval = color; 153 | /* Do color set hacks for hicolor/truecolor modes */ 154 | switch(getmaxcolor()) { 155 | case 32767: 156 | setrgbpalette(1026,xColor.c15.rVal,xColor.c15.gVal,xColor.c15.bVal); 157 | break; 158 | case 65535: 159 | setrgbpalette(1026,xColor.c16.rVal,xColor.c16.gVal,xColor.c16.bVal); 160 | break; 161 | case 16777: 162 | setrgbpalette(1026,xColor.c24.rVal,xColor.c24.gVal,xColor.c24.bVal); 163 | break; 164 | }; 165 | return color; 166 | } 167 | 168 | /* Getvgapalette16 gets the entire 16 color palette */ 169 | /* PalBuf contains RGB values for all 16 colors */ 170 | /* R,G,B values range from 0 to 63 */ 171 | /* Usage: */ 172 | /* DacPalette16 dac16; */ 173 | /* */ 174 | /* getvgapalette(&dac16); */ 175 | void getvgapalette16(DacPalette16 *PalBuf) 176 | { 177 | struct REGPACK reg; 178 | 179 | reg.r_ax = 0x1017; 180 | reg.r_bx = 0; 181 | reg.r_cx = 16; 182 | reg.r_es = FP_SEG(PalBuf); 183 | reg.r_dx = FP_OFF(PalBuf); 184 | intr(0x10,®); 185 | } 186 | 187 | /* Getvgapalette256 gets the entire 256 color palette */ 188 | /* PalBuf contains RGB values for all 256 colors */ 189 | /* R,G,B values range from 0 to 63 */ 190 | /* Usage: */ 191 | /* DacPalette256 dac256; */ 192 | /* */ 193 | /* getvgapalette256(&dac256); */ 194 | void getvgapalette256(DacPalette256 *PalBuf) 195 | { 196 | struct REGPACK reg; 197 | 198 | reg.r_ax = 0x1017; 199 | reg.r_bx = 0; 200 | reg.r_cx = 256; 201 | reg.r_es = FP_SEG(PalBuf); 202 | reg.r_dx = FP_OFF(PalBuf); 203 | intr(0x10,®); 204 | } 205 | 206 | /* Setvgapalette16 sets the entire 16 color palette */ 207 | /* PalBuf contains RGB values for all 16 colors */ 208 | /* R,G,B values range from 0 to 63 */ 209 | /* Usage: */ 210 | /* DacPalette16 dac16; */ 211 | /* */ 212 | /* setvgapalette(&dac16); */ 213 | void setvgapalette16(DacPalette16 *PalBuf) 214 | { 215 | struct REGPACK reg; 216 | 217 | reg.r_ax = 0x1012; 218 | reg.r_bx = 0; 219 | reg.r_cx = 16; 220 | reg.r_es = FP_SEG(PalBuf); 221 | reg.r_dx = FP_OFF(PalBuf); 222 | intr(0x10,®); 223 | } 224 | 225 | /* Setvgapalette256 sets the entire 256 color palette */ 226 | /* PalBuf contains RGB values for all 256 colors */ 227 | /* R,G,B values range from 0 to 63 */ 228 | /* Usage: */ 229 | /* DacPalette256 dac256; */ 230 | /* */ 231 | /* setvgapalette256(&dac256); */ 232 | void setvgapalette256(DacPalette256 *PalBuf) 233 | { 234 | struct REGPACK reg; 235 | 236 | reg.r_ax = 0x1012; 237 | reg.r_bx = 0; 238 | reg.r_cx = 256; 239 | reg.r_es = FP_SEG(PalBuf); 240 | reg.r_dx = FP_OFF(PalBuf); 241 | intr(0x10,®); 242 | } 243 |  -------------------------------------------------------------------------------- /BGIHDR.CPP: -------------------------------------------------------------------------------- 1 | //=========================================================================\\ 2 | // BGIHDR v1.01 \\ 3 | // BGI header generator for BGI v2.0 or BGI v3.0 graphics drivers \\ 4 | // \\ 5 | // Copyright (c) 1993-94 by Jordan Hargraphix \\ 6 | // All Rights Reserved \\ 7 | //=========================================================================\\ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "bgihdr.h" 14 | 15 | char *months[] = {"Jan","Feb","Mar","Apr","May","Jun", 16 | "Jul","Aug","Sep","Oct","Nov","Dec"}; 17 | 18 | char BGICopyrightMsg[] = "Copyright (c) 1990-94 by Jordan Hargraphix"; 19 | 20 | char CopyrightMsg[] = 21 | "\t\t\t BGIHDR v1.01\n" 22 | " BGI header generator for BGI v2.0 or BGI v3.0 graphics drivers\n" 23 | "\t\tCopyright (c) 1993-94 by Jordan Hargraphix\n" 24 | "\t\t\t All Rights Reserved\n" 25 | "============================================================================"; 26 | 27 | char UsageMsg[] = 28 | "Usage: bgihdr drv_name [ driver[.BIN] driver[.BGI] driver[.MAP] ]\n" 29 | "\tdrv_name : Driver name\n" 30 | "\tdriver.BIN : Binary object file generated by exe2bin\n" 31 | "\tdriver.BGI : output BGI driver name\n" 32 | "\tdriver.MAP : Map file generated by TLINK (needed for BGIv3.0 header)\n"; 33 | 34 | //%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@ 35 | // 36 | // Generic BGI Header functions 37 | // 38 | //%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@ 39 | bgiHeader::bgiHeader(char *drvName,int codeSz,int ver,int rev,int subrev, 40 | int minVer,int minRev) 41 | { 42 | strcpy(myName,drvName); 43 | codeSize = codeSz; 44 | version = ver; 45 | revision = rev; 46 | subRev = subrev; 47 | minVersion = minVer; 48 | minRevision = minRev; 49 | driverNum = 0; 50 | } 51 | 52 | inline void bgiHeader::writeHeader(FILE *outFile) 53 | { 54 | putw(HEADER_SIZE,outFile); 55 | putw(driverNum,outFile); 56 | putw(codeSize,outFile); 57 | putc(version,outFile); 58 | putc(revision,outFile); 59 | putc(minVersion,outFile); 60 | putc(minRevision,outFile); 61 | } 62 | 63 | inline void bgiHeader::writeDriverName(FILE *outFile) 64 | { 65 | putc(strlen(myName),outFile); 66 | fprintf(outFile,myName); 67 | } 68 | 69 | //%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@ 70 | // 71 | // BGI Header v2.0 functions 72 | // 73 | //%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@ 74 | bgiHeader2::bgiHeader2(char *drvName,int codeSz) 75 | : bgiHeader(drvName,codeSz,2,0,subRev2,1,0) { }; 76 | 77 | // Checks to see if the buffer contains a valid BGI v2.0 object file 78 | int bgiHeader2::isHeaderValid(const byte *bufr) 79 | { 80 | if ((bufr[0]==0x1E) && (bufr[1]==0x0E) && (bufr[2]==0x1F) && 81 | (bufr[3]==0xFC) && (bufr[12]=='C') && (bufr[13]=='B')) return 0; 82 | return 1; 83 | } 84 | 85 | //%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@ 86 | // 87 | // BGI Header v3.0 functions 88 | // 89 | //%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@ 90 | bgiHeader3::bgiHeader3(char *drvName,unsigned int codeSz, 91 | unsigned int dataOffset,unsigned int dataSz) 92 | : bgiHeader(drvName,codeSz,3,0,subRev3,1,0) 93 | { 94 | dataOfs = dataOffset; 95 | dataSize = dataSz; 96 | } 97 | 98 | // Checks to see if the buffer contains a valid BGI v3.0 object file 99 | inline int bgiHeader3::isHeaderValid(const byte *bufr) 100 | { 101 | if ((bufr[0]==0x1E) && (bufr[1]==0x2E) && (bufr[2]==0x8E) && 102 | (bufr[3]==0x1E)) return 0; 103 | return 1; 104 | } 105 | 106 | inline void bgiHeader3::writeHeader(FILE *outFile) 107 | { 108 | bgiHeader::writeHeader(outFile); 109 | putw(dataOfs,outFile); 110 | putw(dataSize,outFile); 111 | } 112 | 113 | void getFileName(char *fileName,int argc,int argn,char *defL,char *defG,char *ext) 114 | { 115 | if (argc < argn) strcpy(fileName,defL); 116 | else strcpy(fileName,defG); 117 | if (strchr(fileName,'.') == NULL) 118 | strcat(fileName,ext); 119 | } 120 | 121 | int main(int argc,char *argv[]) 122 | { 123 | struct date Date; 124 | char *bgiBufr,*rs; 125 | char fileName[32],drvName[16],ver[16]; 126 | FILE *inFile, *outFile; 127 | int bgiVersion; 128 | bgiHeader *bgiHdr; 129 | long cPos; 130 | unsigned int fileSize; 131 | 132 | printf("%s\n",CopyrightMsg); 133 | if (argc < 2) 134 | { 135 | printf("%s\n",UsageMsg); 136 | exit(1); 137 | } 138 | 139 | // Get driver name 140 | strcpy(drvName,argv[1]); 141 | if ((rs = strchr(drvName,'.')) != NULL) 142 | *rs = '\0'; 143 | strupr(drvName); 144 | 145 | // Open driver.BIN input file 146 | getFileName(fileName,argc,3,drvName,argv[2],".bin"); 147 | inFile = fopen(fileName,"rb"); 148 | if (!inFile) { 149 | printf("ERROR: Couldn't open source[.BIN] file: %s\n",fileName); 150 | exit(2); 151 | } 152 | 153 | // Get the size of the source file 154 | fileSize = filelength(inFile->fd); 155 | // Read in the entire source file 156 | bgiBufr = new char[fileSize]; 157 | fread(bgiBufr,fileSize,1,inFile); 158 | fclose(inFile); 159 | // Read the version number from the source file 160 | bgiVersion = bgiBufr[15]; 161 | 162 | // Create the BGI header object 163 | if (bgiVersion >= 0x3) 164 | { 165 | char bufr[80],dSeg[8]; 166 | unsigned int codeSize,dataOfs,dataSize; 167 | unsigned long dStart; 168 | 169 | codeSize = dataOfs = dataSize = 0; 170 | // Open the driver.MAP file 171 | getFileName(fileName,argc,5,drvName,argv[4],".map"); 172 | inFile = fopen(fileName,"r"); 173 | if (!inFile) { 174 | printf("ERROR: Couldn't open map file: %s\n",fileName); 175 | exit(3); 176 | } 177 | while(1) 178 | { 179 | if (fgets(bufr,80,inFile) == NULL) break; 180 | if (sscanf(bufr,"%lXH %*s %*s %*s %s",&dStart,&dSeg) <= 0) 181 | continue; 182 | if (stricmp(dSeg,"DATA") == 0) { 183 | codeSize = (int)dStart; 184 | dataOfs = (int)dStart; 185 | dataSize = (int)(fileSize - dStart); 186 | break; 187 | } 188 | } 189 | fclose(inFile); 190 | if ((codeSize == 0) || (dataSize == 0)) 191 | { 192 | printf("ERROR: Invalid segment size!\n"); 193 | exit(4); 194 | } 195 | bgiHdr = new bgiHeader3(drvName,codeSize,dataOfs,dataSize); 196 | } 197 | else 198 | bgiHdr = new bgiHeader2(drvName,fileSize); 199 | 200 | // Check to see if input file was valid 201 | if (bgiHdr->isHeaderValid(bgiBufr)) 202 | { 203 | printf("Error: Unknown driver type! (%d)\n",bgiVersion); 204 | exit(5); 205 | } 206 | printf("Input file is BGI version %d.0\t",bgiVersion); 207 | 208 | // Open driver.BGI output file 209 | getFileName(fileName,argc,4,drvName,argv[3],".bgi"); 210 | outFile = fopen(fileName,"wb"); 211 | if (!outFile) { 212 | printf("ERROR: Couldn't open output[.BGI] file: %s\n",fileName); 213 | exit(3); 214 | } 215 | 216 | // Get the version number for the driver 217 | if (!(inFile = fopen("svga_ver.db","r"))) { 218 | printf("\nEnter version #: "); 219 | scanf("%s",ver); 220 | } else 221 | { 222 | char ver_driver[16]; 223 | 224 | // Scan SVGA_VER.DB file for current driver version 225 | while(!feof(inFile)) { 226 | if (fscanf(inFile,"%s %s\n",ver_driver,ver) <= 0) { 227 | printf("\nEnter version #: "); 228 | scanf("%s",ver); 229 | break; 230 | } 231 | if (stricmp(ver_driver,drvName) == 0) 232 | break; 233 | } 234 | fclose(inFile); 235 | } 236 | printf("Output file is release version: %s\n",ver); 237 | 238 | // Write header text and copyright message 239 | getdate(&Date); 240 | fprintf(outFile,"%s%s BGI Device Driver (%s) %s - %s %.2d, %d\r\n", 241 | bgiHdr->header(),drvName,drvName,ver,months[Date.da_mon-1], 242 | Date.da_day,Date.da_year); 243 | fprintf(outFile,"%s\r\n",BGICopyrightMsg); 244 | putc(0x00,outFile); 245 | putc(0x1A,outFile); 246 | 247 | // Write header information 248 | bgiHdr->writeHeader(outFile); 249 | // pad to 0x80 250 | for(cPos=ftell(outFile);cPos<0x80;cPos++) putc(0x00,outFile); 251 | 252 | // Write header information, followed by driver name 253 | bgiHdr->writeHeader(outFile); 254 | bgiHdr->writeDriverName(outFile); 255 | // pad to HEADER_SIZE 256 | for(cPos=ftell(outFile);cPos 6 | ;; All rights reserved 7 | ;; 8 | ;; This is Copyrighted software. 9 | ;; Permission is hereby granted to use this source code for 10 | ;; private use only. It may NOT be distributed without permission 11 | ;; of the author. 12 | ;; 13 | ;; If you have any comments about changes or improvements in this code, 14 | ;; please let me know. 15 | ;; 16 | ;; Revision history: 17 | ;; ----------------- 18 | ;; $Log: C:/svga/rcs/twktext.asv $ 19 | ; 20 | ; Rev 1.2 23 Aug 1994 0:05:46 JORDAN 21 | ; 22 | ; Rev 1.1 26 Jul 1994 22:47:54 JORDAN 23 | ; Line/Patbar/GetPixel working 24 | ; (line is slow..) 25 | ; 26 | ; Rev 1.14 20 Jul 1994 22:09:28 JORDAN 27 | ; Added support for HGXMOUSE driver. 28 | ; 29 | ; Rev 1.13 09 Jun 1994 23:48:36 JORDAN 30 | ; 31 | ; Rev 1.12 14 May 1994 19:36:08 JORDAN 32 | ;; 33 | .186 34 | 35 | IFNDEF BGIVERSION 36 | BGIVERSION EQU 2 ;; BGI revision version 37 | ;; 2 for most BC/TC and BP/TP 38 | ;; 3 for BP7.0 protected mode 39 | ENDIF 40 | MaxMode EQU 1 ; Maximum mode supported 41 | ;; Change here for font used: 42 | ;; 8 = 8x8 font 43 | ;; 14 = 8x14 font 44 | ;; 16 = 8x16 font 45 | TEXTBYTES EQU 8 46 | 47 | INCLUDE common.inc ; Common defines 48 | 49 | SC_INDEX EQU 03c4h 50 | GC_INDEX EQU 03ceh 51 | CRTC_INDEX EQU 03d4h 52 | MISC_OUTPUT EQU 03c2h 53 | MAP_MASK EQU 2 54 | READ_MAP EQU 4 55 | 56 | fontHeight EQU 32 57 | fontChars EQU 512 58 | fontSize EQU fontHeight * fontChars 59 | screenWidth EQU 40 60 | screenHeight EQU 350/fontHeight 61 | 62 | IF BGIVERSION LT 3 63 | 64 | .model SMALL 65 | .CODE 66 | 67 | assume cs:_TEXT,ds:_TEXT,ss:_TEXT 68 | 69 | ;; BGI v2.0 entry code 70 | BGI20Entry 71 | 72 | ELSE 73 | 74 | _TEXT SEGMENT PARA PUBLIC 'CODE' 75 | 76 | assume cs:_TEXT, ds:_DATA 77 | 78 | ;; BGI v3.0 entry code 79 | BGI30Entry 80 | 81 | ENDIF 82 | 83 | ;; EMULATE - Far call to emulation routines in BGI kernel 84 | ;; This area is updated by GRAPH at loadtime 85 | EMULATE: ret 86 | dw 0,0 87 | 88 | ;; Dummy routines for unimplemented procedures 89 | ;; Near return 90 | NotImpNear proc near 91 | ret 92 | NotImpNear endp 93 | 94 | ;; Far return 95 | NotImpFar proc far 96 | ret 97 | NotImpFar endp 98 | 99 | INCLUDE macros.inc 100 | 101 | ;; Restregs - restore default register values 102 | restregs: mov dx,GC_INDEX 103 | mov ax,3 104 | out dx,ax 105 | ret 106 | 107 | ;-------------------------------------------------------------------- 108 | ;;INSTALL - Installs the driver 109 | 110 | install: cmp al,1 111 | jnz notmodequery 112 | mov cx,MaxMode ;; Return # of modes 113 | ret 114 | notmodequery: cmp cl,MaxMode-1 115 | jle TopMode 116 | mov cl,MaxMode-1 117 | TopMode: LoadDataSeg es 118 | xor ch,ch 119 | mov si,cx 120 | shl si,1 121 | test al,al 122 | jz notmodename 123 | mov bx,[si+ModeNameTable] ;; Return mode name 124 | ret 125 | notmodename: mov curr_mode,cl 126 | push es 127 | mov ax,01130h ;; Load pointer to the ROM 128 | if TEXTBYTES EQ 14 129 | mov bh,2 ;; 8x14 font 130 | ENDIF 131 | if TEXTBYTES EQ 16 132 | mov bh,6 ;; 8x16 font 133 | ENDIF 134 | if TEXTBYTES EQ 8 135 | mov bh,3 ;; 8x8 font 136 | ENDIF 137 | int 10h 138 | mov textofs,bp 139 | IF BGIVERSION GE 3 140 | mov es,SEGC000 ;; Evil hack... Couldn't get DPMI 141 | ;; to make the actual segment readable 142 | ENDIF 143 | mov textseg,es 144 | pop es 145 | mov bx,[StatTable+si] ;; Get address of DIT 146 | mov ax,[bx+yefres] 147 | mov ysiz,ax 148 | mov ax,[bx+xefres] 149 | inc ax 150 | mov xsiz,ax 151 | 152 | mov ax, screenHeight*fontHeight 153 | mov xbytes,ax 154 | InstallOk: ret 155 | 156 | ;--------------------------------------------------------------------- 157 | ;;INIT - Changes into graphics mode 158 | ;; ES:BX=Device Information Table 159 | 160 | init: 161 | ;; Set 350 line mode 162 | mov ax, 1201h 163 | mov bx, 0030h 164 | int 010h 165 | 166 | ;; Set 40x25 mode 167 | mov ax, 01h 168 | int 010h 169 | 170 | ;; Set lines per char 171 | mov ax, 01110h 172 | mov bh, fontHeight 173 | xor bl, bl 174 | mov cx, 512 175 | xor dx, dx 176 | mov si, cs 177 | mov es, si 178 | xor bp, bp 179 | int 010h 180 | 181 | ;; Set palette color for color 7 182 | mov ax, 1000h 183 | mov bx, 03f07h 184 | int 010h 185 | 186 | ;; Set character generators A=1 and B=5 187 | outpw 03C4h, 02003h 188 | 189 | ;; Fill screen with 512 unique characters 190 | ;; Characters are organized like this: 191 | ;; 0 n 2n 3n ... 192 | ;; 1 n+1 2n+1 3n+1 ... 193 | ;; 2 n+2 2n+2 3n+2 ... 194 | ;; ................... 195 | 196 | mov es, [VidMem] 197 | xor di, di 198 | mov cx, screenWidth 199 | xor ax, ax ;; count 200 | mov dx, 0700h ;; color 201 | @charHLoop: push cx 202 | push di 203 | mov cx, screenHeight 204 | @charVLoop: cmp ax, 256 205 | jnz @notUpchar 206 | or dx, 800h ;; Mask for 2nd charset 207 | @notUpchar: push ax 208 | or ax, dx 209 | mov word ptr es:[di], ax 210 | pop ax 211 | ;; Increase Y coordinate 212 | add di, screenWidth*2 213 | inc ax 214 | loop @charVLoop 215 | pop di 216 | pop cx 217 | ;; Increase X coordinate 218 | add di, 2 219 | loop @charHLoop 220 | 221 | ;;--------------------------------------------------- 222 | ;; Enable bitplane 2 (character definition map) 223 | plane = 2 224 | outpw 03C4h, <(((1 SHL plane) SHL 8) OR 2)> 225 | ;; Sequential addressing 226 | outpw 03c4h, 0704h 227 | ;; Disable odd-even addressing 228 | outpw 03ceh, 05h 229 | ;; Memory map = A000-AFFF 230 | outpw 03ceh, 0406h 231 | ;; Select map 2 for CPU reads 232 | outpw 03ceh, <((plane SHL 8) OR 4)> 233 | ;; Color-don't care register 234 | outpw 03ceh, 0ff07h 235 | 236 | ;; Clear font memory 237 | call clear 238 | 239 | ;; Enable mouse 240 | Enable_Mouse MODE_TWKTEXT 241 | ret 242 | 243 | ;--------------------------------------------------------------------- 244 | ;;POST - Exit from graphics mode 245 | 246 | post: Disable_Mouse 247 | 248 | ;; Set 50 lines mode 249 | mov ax, 1202h 250 | mov bx, 0030h 251 | int 010h 252 | 253 | ret 254 | 255 | ;--------------------------------------------------------------------- 256 | ;;CLEAR - Clears the screen 257 | 258 | ;; Clear font memory 259 | clear: mov es, [FontMem] 260 | mov cx, fontSize 261 | xor al, al 262 | xor di, di 263 | repz stosb 264 | ret 265 | 266 | ;--------------------------------------------------------------------- 267 | ;;MOVE - Moves the current draw pointer to X,Y 268 | ;; AX=New X coordinate 269 | ;; BX=New Y coordinate 270 | 271 | move: mov cp_x,ax 272 | mov cp_y,bx 273 | ret 274 | 275 | ;--------------------------------------------------------------------- 276 | ;;DRAW - Draws line from CP to X,Y 277 | ;; AX=End X coordinate 278 | ;; BX=End Y coordinate 279 | 280 | draw: mov cx,cp_x 281 | mov dx,cp_y 282 | mov cp_x,ax ;; Update drawing pointer 283 | mov cp_y,bx 284 | 285 | ;--------------------------------------------------------------------- 286 | ;;VECT - Draws line from X1,Y1 to X2,Y2 287 | ;; AX=Start X coordinate 288 | ;; BX=Start Y coordinate 289 | ;; CX=End X coordinate 290 | ;; DX=End Y coordinate 291 | ;; 292 | ;; Bresenhams ine drawing algorithm from Bluebook of Assembly Routines for 293 | ;; the IBM PC & XT, with minor modifications :jph 294 | 295 | vect: mov si, 1 ;; X increment 296 | mov di, 1 ;; Y increment 297 | 298 | cmp ax, cx 299 | jle vok 300 | xchg ax, cx 301 | xchg bx, dx 302 | 303 | vok: sub cx,ax ;; Check if X2 xr 765 | jg @ScnRgtSExit 766 | mov ax,si ;; TstPix 767 | mov bx,[bp+8] 768 | call getpixel 769 | cmp dl,BrdrClr 770 | je @ScnRgtS00 771 | mov ax,si ;; return x 772 | jmp short @ScnRgtS02 773 | @ScnRgtSExit: mov ax,-1 ;; return -1 774 | @ScnRgtS02: pop si 775 | pop di 776 | pop bp 777 | ret 778 | 779 | ;--------------------------------------------------------------------------- 780 | ;;FillHoriz - Fills a horizontal line 781 | 782 | FillHoriz: push bp 783 | mov bp,sp 784 | push di 785 | push si 786 | mov si,[bp+4] ; x 787 | mov di,[bp+6] ; y 788 | mov ax,CurrXR 789 | mov PrevXR,ax 790 | push di 791 | push si 792 | call ScanRight 793 | add sp,4 794 | mov CurrXR,ax ; Xr 795 | mov cx,si 796 | mov dx,di ; Y 797 | mov bx,di ; Y 798 | call patbar 799 | pop si 800 | pop di 801 | pop bp 802 | ret 803 | 804 | ;--------------------------------------------------------------------------- 805 | ;;ScanLine - Scans a line, adding entries to the fill stack 806 | 807 | ScanLine: push bp 808 | mov bp,sp 809 | push di 810 | push si 811 | mov si,[bp+4] ; xl 812 | mov di,[bp+6] ; xr 813 | jmp short @ScnLin02 814 | @ScnLin00: mov bx,StkPtr 815 | shl bx,1 816 | mov ax,si 817 | cmp word ptr [bp+10],0 ; dir 818 | jge @ScnLin01 819 | not ax 820 | @ScnLin01: mov Xvals[bx],ax ;; Add left x coord to stack 821 | mov ax,[bp+8] ; y 822 | mov Yvals[bx],ax ;; Add y coord to stack 823 | inc StkPtr ;; Increase stack pointer 824 | push ax 825 | push si 826 | call ScanRight 827 | add sp,4 828 | mov si,ax 829 | inc si 830 | @ScnLin02: push [bp+8] ; y 831 | push di 832 | push si 833 | call ScanRightS 834 | add sp,6 835 | mov si,ax 836 | test si,si 837 | jl @ScnLinExit 838 | cmp StkPtr,MaxStack 839 | jne @ScnLin00 840 | mov ax,-1 841 | jmp short @ScnLin03 842 | @ScnLinExit: sub ax,ax 843 | @ScnLin03: pop si 844 | pop di 845 | pop bp 846 | ret 847 | 848 | ;--------------------------------------------------------------------------- 849 | ;;ChkStk - Checks if a coord is in the fill stack 850 | 851 | ChkStk: push bp 852 | mov bp,sp 853 | push di 854 | push si 855 | mov si,[bp+4] ; x 856 | sub di,di 857 | cmp [bp+8],di ; dir 858 | jge @ChkStk00 859 | not si 860 | @ChkStk00: mov dx,[bp+6] ; y 861 | mov cx,StkPtr 862 | jmp short @ChkStk04 863 | @ChkStk01: mov bx,di 864 | shl bx,1 865 | mov ax,Xvals[bx] ;; Remove duplicate entry 866 | mov Xvals[bx-2],ax 867 | mov ax,Yvals[bx] 868 | mov Yvals[bx-2],ax 869 | @ChkStk02: inc di 870 | cmp di,cx 871 | jl @ChkStk01 872 | dec cx ; Decrease stack pointer 873 | mov ax,1 ; return 1 874 | jmp short @ChkStk05 875 | @ChkStk03: inc di 876 | @ChkStk04: cmp cx,di 877 | jle @ChkStkExit 878 | mov bx,di 879 | shl bx,1 880 | cmp Xvals[bx],si ; Compare x with stack 881 | jne @ChkStk03 882 | cmp Yvals[bx],dx ; Compare y with stack 883 | jne @ChkStk03 884 | jmp short @ChkStk02 885 | @ChkStkExit: sub ax,ax ; return 0 886 | @ChkStk05: mov StkPtr,cx 887 | pop si 888 | pop di 889 | pop bp 890 | ret 891 | 892 | ;--------------------------------------------------------------------------- 893 | ;;ScanUpDn - Scans up or down until a boundary is reached 894 | 895 | ScanUpDn: push bp 896 | mov bp,sp 897 | sub sp,18 898 | push di 899 | push si 900 | mov ax,[bp+8] ;Dir 901 | neg ax 902 | mov [bp-18],ax 903 | @ScnUpDn00: mov ax,[bp+6] ;Yc 904 | add ax,[bp+8] ;Dir 905 | mov [bp-6],ax ;CurrY 906 | mov ax,clip_y1 907 | cmp [bp-6],ax ;CurrY 908 | jl @ScnUpDn01 909 | mov ax,clip_y2 910 | cmp [bp-6],ax ;CurrY 911 | jle @ScnUpDn02 912 | @ScnUpDn01: sub ax,ax 913 | jmp @ScnUpDnExit 914 | @ScnUpDn02: mov ax,[bp+4] ;Xc 915 | mov [bp-4],ax ;PrevXL 916 | mov bx,[bp-6] ;; TstPix 917 | call getpixel 918 | cmp dl,BrdrClr 919 | je @ScnUpDn03 920 | push [bp-6] ;CurrY 921 | push [bp+4] ;Xc 922 | call ScanLeft 923 | add sp,4 924 | mov [bp-2],ax ;CurrXL 925 | jmp short @ScnUpDn04 926 | @ScnUpDn03: push [bp-6] ;CurrY 927 | push CurrXR 928 | push [bp+4] ;Xc 929 | call ScanRightS 930 | add sp,6 931 | mov [bp-2],ax ;CurrXL 932 | test ax,ax 933 | jl @ScnUpDn01 934 | @ScnUpDn04: push [bp-6] ;CurrY 935 | push [bp-2] ;CurrXL 936 | call FillHoriz 937 | add sp,4 938 | mov ax,[bp-4] ;PrevXL 939 | cmp [bp-2],ax ;CurrXL 940 | jge @ScnUpDn10 941 | mov si,[bp-2] ;CurrXL 942 | push [bp+6] ;Yc 943 | push si 944 | call ScanLeft 945 | add sp,4 946 | mov di,ax 947 | cmp di,si 948 | jge @ScnUpDn08 949 | jmp short @ScnUpDn06 950 | @ScnUpDn05: mov si,di 951 | push [bp+6] ;Yc 952 | push si 953 | call ScanLeft 954 | add sp,4 955 | mov di,ax 956 | @ScnUpDn06: cmp di,si 957 | jge @ScnUpDn07 958 | mov si,di 959 | push [bp-6] ;CurrY 960 | push si 961 | call ScanLeft 962 | add sp,4 963 | mov di,ax 964 | cmp di,si 965 | jl @ScnUpDn05 966 | @ScnUpDn07: push [bp+8] ;Dir 967 | push [bp-6] ;CurrY 968 | mov ax,[bp-2] ;CurrXL 969 | dec ax 970 | push ax 971 | push si 972 | call ScanLine 973 | add sp,8 974 | test ax,ax 975 | jne @ScnUpDn09 976 | @ScnUpDn08: push [bp-18] 977 | push [bp+6] ;Yc 978 | mov ax,[bp-4] ;PrevXL 979 | dec ax 980 | push ax 981 | push si 982 | call ScanLine 983 | add sp,8 984 | test ax,ax 985 | je @ScnUpDn10 986 | @ScnUpDn09: mov ax,-1 987 | @ScnUpDnExit: pop si 988 | pop di 989 | mov sp,bp 990 | pop bp 991 | ret 992 | @ScnUpDn10: mov ax,CurrXR 993 | cmp PrevXR,ax 994 | jne @ScnUpDn11 995 | jmp @ScnUpDn17 996 | @ScnUpDn11: mov ax,[bp+8] ;Dir 997 | mov [bp-8],ax ;FillD 998 | mov ax,CurrXR 999 | mov [bp-4],ax ;PrevXL 1000 | mov ax,PrevXR 1001 | mov [bp-14],ax ;NewXL 1002 | mov ax,CurrXR 1003 | cmp PrevXR,ax 1004 | jle @ScnUpDn12 1005 | mov ax,[bp-14] ;NewXL 1006 | xchg ax,[bp-4] ;PrevXL 1007 | mov [bp-14],ax 1008 | mov ax,[bp-6] ;CurrY 1009 | mov [bp+6],ax ;Yc 1010 | mov ax,[bp-8] ;FillD 1011 | neg ax 1012 | mov [bp-8],ax ;FillD 1013 | @ScnUpDn12: mov si,[bp-4] ;PrevXL 1014 | push [bp+6] ;Yc 1015 | push si 1016 | call ScanRight 1017 | add sp,4 1018 | mov di,ax 1019 | cmp di,si 1020 | jle @ScnUpDn16 1021 | jle @ScnUpDn14 1022 | mov ax,[bp+6] ;Yc 1023 | add ax,[bp-8] ;FillD 1024 | mov [bp-16],ax 1025 | @ScnUpDn13: mov si,di 1026 | push [bp-16] 1027 | push si 1028 | call ScanRight 1029 | add sp,4 1030 | mov di,ax 1031 | cmp di,si 1032 | jg @ScnUpDn15 1033 | @ScnUpDn14: push [bp-8] ;FillD 1034 | mov ax,[bp+6] ;Yc 1035 | add ax,[bp-8] ;FillD 1036 | push ax 1037 | push si 1038 | mov ax,[bp-4] ;PrevXL 1039 | inc ax 1040 | push ax 1041 | call ScanLine 1042 | add sp,8 1043 | test ax,ax 1044 | je @ScnUpDn16 1045 | jmp @ScnUpDn09 1046 | @ScnUpDn15: mov si,di 1047 | push [bp+6] ;Yc 1048 | push si 1049 | call ScanRight 1050 | add sp,4 1051 | mov di,ax 1052 | cmp di,si 1053 | jle @ScnUpDn14 1054 | jmp short @ScnUpDn13 1055 | @ScnUpDn16: mov ax,[bp-8] ;FillD 1056 | neg ax 1057 | push ax 1058 | push [bp+6] ;Yc 1059 | push si 1060 | mov ax,[bp-14] ;NewXL 1061 | inc ax 1062 | push ax 1063 | call ScanLine 1064 | add sp,8 1065 | test ax,ax 1066 | je @ScnUpDn17 1067 | jmp @ScnUpDn09 1068 | @ScnUpDn17: mov ax,[bp-2] ;CurrXL 1069 | mov [bp+4],ax ;Xc 1070 | mov ax,[bp-6] ;CurrY 1071 | mov [bp+6],ax ;Yc 1072 | push [bp-18] 1073 | push ax 1074 | push [bp+4] ;Xc 1075 | call ChkStk 1076 | add sp,6 1077 | test ax,ax 1078 | jne @ScnUpDn18 1079 | jmp @ScnUpDn00 1080 | @ScnUpDn18: jmp @ScnUpDn01 1081 | 1082 | ;--------------------------------------------------------------------- 1083 | ;;FLOODFILL - Fills a bounded region with a pattern 1084 | ;; AX=X coordinate of the seed point 1085 | ;; BX=Y coordinate of the seed point 1086 | ;; CL=Boundary colour for fill 1087 | 1088 | FloodFill: ret 1089 | 1090 | mov word ptr FillD,-1 1091 | mov BrdrClr,cl 1092 | mov si,ax ;; SeedX 1093 | mov di,bx ;; SeedY 1094 | call getpixel ;; TstPix 1095 | cmp dl,BrdrClr 1096 | jne @FldFill_00 1097 | jmp short @FldFill_Exit 1098 | @FldFill_00: push di ;; SeedY 1099 | push si ;; SeedX 1100 | call ScanLeft 1101 | add sp,4 1102 | mov si,ax ;; SeedX 1103 | mov Xvals,ax 1104 | mov Yvals,di ;; SeedY 1105 | mov StkPtr,1 1106 | push di ;; SeedY 1107 | push si ;; SeedX 1108 | call ScanRight 1109 | add sp,4 1110 | mov CurrXR,ax 1111 | jmp short @FldFill_03 1112 | @FldFill_01: mov bx,StkPtr 1113 | test bx,bx 1114 | je @FldFill_Exit 1115 | dec bx 1116 | mov StkPtr,bx 1117 | shl bx,1 1118 | mov si,Xvals[bx] 1119 | mov di,Yvals[bx] 1120 | mov ax,1 1121 | test si,si 1122 | jge @FldFill_02 1123 | not si 1124 | neg ax 1125 | @FldFill_02: mov FillD,ax 1126 | push di 1127 | push si 1128 | call FillHoriz 1129 | add sp,4 1130 | mov ax,FillD 1131 | neg ax 1132 | push ax 1133 | push di 1134 | push si 1135 | call ChkStk 1136 | add sp,6 1137 | test ax,ax 1138 | jne @FldFill_01 1139 | @FldFill_03: push FillD 1140 | push di 1141 | push si 1142 | call ScanUpDn 1143 | add sp,6 1144 | test ax,ax 1145 | je @FldFill_01 1146 | @FldFill_Exit: ret 1147 | 1148 | ;--------------------------------------------------------------------- 1149 | ;;GETPIXEL - Reads a pixel from the screen 1150 | ;; AX=X coordinate of the seed point 1151 | ;; BX=Y coordinate of the seed point 1152 | ;; 1153 | ;; Code from John Bridges' VGAKIT 1154 | 1155 | getpixel: ret 1156 | 1157 | mov cx,ax 1158 | xchg ax,bx 1159 | shr bx,1 1160 | shr bx,1 1161 | mul xbytes ;; Calculate offset of pixel 1162 | add bx,ax 1163 | add bx,PageOfs 1164 | and cl,3 1165 | mov ah,cl 1166 | mov al,READ_MAP 1167 | mov dx,GC_INDEX 1168 | out dx,ax 1169 | mov es,VidMem 1170 | xor dx,dx 1171 | mov dl,es:[bx] ;; Read pixel colour 1172 | ret 1173 | 1174 | ;--------------------------------------------------------------------- 1175 | ;;PUTPIXEL - Writes a pixel to the screen 1176 | ;; AX=X coordinate of the seed point 1177 | ;; BX=Y coordinate of the seed point 1178 | ;; DL=colour of the seed point 1179 | ;; 1180 | ;; Code from John Bridges' VGAKIT 1181 | 1182 | putpixel: push cx 1183 | mov cx, ax 1184 | shr ax, 3 1185 | mul [xbytes] 1186 | add bx, ax 1187 | 1188 | mov es, [FontMem] 1189 | and cl, 7 1190 | mov ch, 080h 1191 | shr ch, cl 1192 | 1193 | or es:[bx], ch 1194 | pop cx 1195 | ret 1196 | 1197 | ;--------------------------------------------------------------------- 1198 | ;;BITMAPUTIL - Returns pointer to bitmap routines 1199 | bitmaputil: LoadDataSeg es 1200 | mov bx,offset BitmapTable 1201 | ret 1202 | 1203 | ;--------------------------------------------------------------------- 1204 | ;;BITBLT from screen to buffer 1205 | ;; ES:BX=memory buffer to store image in 1206 | ;; ES:[BX+0]=(Width of rectangle - 1) 1207 | ;; ES:[BX+2]=(Height of rectangle - 1) 1208 | ;; CX=Upper left X coordinate 1209 | ;; DX=Upper left Y coordinate 1210 | 1211 | savebitmap: ret 1212 | 1213 | mov ax,es:[bx] ;; Width of image-1 1214 | inc ax 1215 | mov bar_xsiz,ax 1216 | 1217 | mov ax,dx ;; Calculate offset of first row 1218 | mov di,cx 1219 | shr di,1 1220 | shr di,1 1221 | mul xbytes 1222 | add di,ax 1223 | add di,PageOfs 1224 | and cl,3 1225 | mov ah,cl 1226 | mov si,es:[bx+2] ;; Height of image-1 1227 | add bx,4 1228 | 1229 | mov dx,GC_INDEX 1230 | GetLoopY: mov cx,bar_xsiz 1231 | push ax 1232 | push di 1233 | GetLoopX: mov al,READ_MAP 1234 | out dx,ax 1235 | push es 1236 | mov es,VidMem 1237 | mov al,es:[di] ;; Get pixel from screen 1238 | pop es 1239 | mov es:[bx],al ;; Store pixel in buffer 1240 | 1241 | add bx,1 ;; Check for >64k access 1242 | jnz NIseg 1243 | push ax 1244 | mov ax,es 1245 | add ax,01000h 1246 | mov es,ax 1247 | cmp ax,09000h ;; Check for end of memory 1248 | pop ax 1249 | ja GetExit 1250 | NIseg: inc ah 1251 | cmp ah,4 1252 | jnz noGetBk 1253 | inc di 1254 | xor ah,ah 1255 | noGetBk: loop GetLoopX 1256 | pop di 1257 | add di,xbytes ;; Increment offset to next row 1258 | pop ax 1259 | dec si ;; Decrease y counter 1260 | jns GetLoopY 1261 | GetExit: ret 1262 | 1263 | ;--------------------------------------------------------------------- 1264 | ;;BITBLT from buffer to screen 1265 | ;; ES:BX=memory buffer with stored image 1266 | ;; ES:[BX+0]=(Width of rectangle - 1) 1267 | ;; ES:[BX+2]=(Height of rectangle - 1) 1268 | ;; CX=Upper left X coordinate 1269 | ;; DX=Upper left Y coordinate 1270 | ;; AL=Logical restore operation 1271 | ;; 0 - COPY_PUT 4 - NOT_PUT 8 - TRANS_COPY_PUT 1272 | ;; 1 - XOR_PUT 5 - XNOR_PUT 1273 | ;; 2 - OR_PUT 6 - NOR_PUT 1274 | ;; 3 - AND_PUT 7 - NAND_PUT 1275 | 1276 | restorebitmap: ret 1277 | 1278 | mov bltmode,al 1279 | xor ah,ah 1280 | mov si,ax 1281 | mov ah,Logical[si] 1282 | push dx ;; Set pixel update fn 1283 | mov dx,GC_INDEX 1284 | mov al,3 1285 | out dx,ax 1286 | pop dx 1287 | mov si,es:[bx] ;; Width of image-1 1288 | inc si 1289 | mov bar_xsiz,si 1290 | 1291 | mov ax,dx ;; Calculate offset of first row 1292 | mov di,cx 1293 | shr di,1 1294 | shr di,1 1295 | mul xbytes 1296 | add di,ax 1297 | add di,PageOfs 1298 | and cl,3 1299 | mov ah,011h 1300 | rol ah,cl 1301 | mov si,es:[bx+2] ;; Height of image-1 1302 | add bx,4 1303 | 1304 | mov dx,SC_INDEX 1305 | PutLoopY: mov cx,bar_xsiz 1306 | push ax 1307 | push di 1308 | PutLoopX: mov al,MAP_MASK 1309 | out dx,ax 1310 | mov al,es:[bx] ;; Get pixel out of buffer 1311 | push es 1312 | mov es,VidMem 1313 | cmp bltmode,8 ;; TRANS_COPY_PIX 1314 | jnz notTCP 1315 | test al,al ;; If color 0, don't plot 1316 | jnz doPUT 1317 | jmp short noPUT 1318 | notTCP: cmp bltmode,4 ;; Check for NOR, NXOR, etc.. 1319 | jl doPUT 1320 | not al 1321 | doPUT: xchg es:[di],al ;; Store it! 1322 | noPUT: pop es 1323 | add bx,1 ;; Check for >64k access 1324 | jnz NOseg 1325 | push ax 1326 | mov ax,es 1327 | add ax,01000h 1328 | mov es,ax 1329 | cmp ax,09000h ;; Check for end of memory 1330 | pop ax 1331 | ja PutExit 1332 | NOseg: rol ah,1 1333 | jnc noPutBk 1334 | inc di 1335 | noPutBk: loop PutLoopX 1336 | pop di 1337 | add di,xbytes 1338 | pop ax 1339 | dec si ;; Decrease y counter 1340 | jns PutLoopY 1341 | PutExit: jmp restregs 1342 | 1343 | ;--------------------------------------------------------------------- 1344 | ;; SETCLIP - Sets the clipping rectangle 1345 | ;; AX=Upper left X coordinate 1346 | ;; BX=Upper left Y coordinate 1347 | ;; CX=Lower right X coordinate 1348 | ;; DX=Lower right Y coordinate 1349 | 1350 | setclip: mov clip_x1,ax 1351 | mov clip_y1,bx 1352 | mov clip_x2,cx 1353 | mov clip_y2,dx 1354 | ret 1355 | 1356 | ;--------------------------------------------------------------------- 1357 | ;; COLOURQUERY - colour & palette info 1358 | 1359 | ;; Get length of colour table & number of colours available 1360 | colourquery: test al,al 1361 | jnz clrtable 1362 | xor bx,bx 1363 | mov cx,1 1364 | ret 1365 | 1366 | ;; Get offset of colour table 1367 | clrtable: LoadDataSeg es 1368 | mov bx,offset colourtable 1369 | ret 1370 | 1371 | ;--------------------------------------------------------------------- 1372 | ; Now for the miscellaneous routines 1373 | 1374 | ;; BITS_PER_PIX - Returns the pixel colour depth 1375 | bits_per_pix proc far 1376 | mov ax,8 1377 | ret 1378 | bits_per_pix endp 1379 | 1380 | ;; SETWRITEMODE - Sets the line drawing mode 1381 | setwritemode proc far 1382 | and ax,1 1383 | push ds 1384 | LoadDataSeg ds 1385 | mov writemode,ax 1386 | pop ds 1387 | ret 1388 | setwritemode endp 1389 | 1390 | pageadr proc 1391 | push dx 1392 | mov bx,ax 1393 | mov dx,CRTC_INDEX 1394 | 1395 | mov al,0dh 1396 | out dx,al 1397 | inc dx 1398 | mov al,bl 1399 | out dx,al 1400 | dec dx 1401 | 1402 | mov al,0ch 1403 | out dx,al 1404 | inc dx 1405 | mov al,bh 1406 | out dx,al 1407 | pop dx 1408 | ret 1409 | pageadr endp 1410 | 1411 | ;; SETVISPAGE - Sets the visible video page 1412 | setvispage proc far 1413 | push cx 1414 | push ds 1415 | LoadDataSeg ds 1416 | call getdrawpage 1417 | call pageadr 1418 | pop ds 1419 | pop cx 1420 | ret 1421 | setvispage endp 1422 | 1423 | getdrawpage proc 1424 | mov bl,curr_mode 1425 | xor bh,bh 1426 | xor ah,ah 1427 | shl bx,1 1428 | mov cx,ax 1429 | xor ax,ax 1430 | jcxz spage_it 1431 | spage1: add ax,word ptr [bx+PageSize] 1432 | loop spage1 1433 | spage_it: ret 1434 | getdrawpage endp 1435 | 1436 | ;; SETDRAWPAGE - Sets the drawing video page 1437 | setdrawpage proc far 1438 | push cx 1439 | push ds 1440 | LoadDataSeg ds 1441 | call getdrawpage 1442 | mov word ptr [PageOfs],ax 1443 | pop ds 1444 | pop cx 1445 | ret 1446 | setdrawpage endp 1447 | 1448 | IF BGIVERSION GE 3 1449 | _TEXT ENDS 1450 | 1451 | _DATA SEGMENT PARA PUBLIC 'DATA' 1452 | 1453 | assume ds:_DATA, cs:Nothing 1454 | 1455 | InitTable EQU $ 1456 | NRealSegs db 4 1457 | RealSegOfs dw SegTable 1458 | NIntVects db 1 1459 | IntVecOfs dw VectTable 1460 | NRealBlocks db 0 1461 | RealBlockOfs dw 0 1462 | DSinRealMem db 1 1463 | RealModeDS dw 0 1464 | CurOpMode db 0 1465 | 1466 | SegTable EQU $ 1467 | SEG0040 dw 00040h 1468 | SEGA000 dw 0A000h 1469 | SEGC000 dw 0C000h 1470 | SEGF000 dw 0F000h 1471 | 1472 | VectTable EQU $ 1473 | ChrGen dd 0000001fh 1474 | 1475 | ENDIF 1476 | 1477 | ;;Indexed call table of BGI routines 1478 | DDOVEC dw install ;[00] Install the driver 1479 | dw init ;[02] Initialize the driver 1480 | dw clear ;[04] Clear the graphics device 1481 | dw post ;[06] Exit from graphics mode 1482 | dw move ;[08] Move current pointer 1483 | dw draw ;[0A] Draw line from CP to X,Y 1484 | dw vect ;[0C] Draw line from X1,Y1 to X2,Y2 1485 | dw EMULATE ;[0E] Reserved 1486 | dw EMULATE ;[10] Filled 3d bar {emulated} 1487 | dw patbar ;[12] Patterned bar 1488 | dw EMULATE ;[14] Arc {emulated} 1489 | dw EMULATE ;[16] Pieslice {emulated} 1490 | dw EMULATE ;[18] Filled ellipse {emulated} 1491 | dw palette ;[1A] Load a palette entry 1492 | dw NotImpNear ;[1C] Load the full palette 1493 | dw colour ;[1E] Set current line/fill colour 1494 | dw fillstyle ;[20] Set fill pattern 1495 | dw linestyle ;[22] Set line style 1496 | dw textstyle ;[24] Default font control 1497 | dw text ;[26] Default font output at CP 1498 | dw textsize ;[28] Default font size query 1499 | dw EMULATE ;[2A] Reserved 1500 | dw floodfill ;[2C] Fill a bounded region 1501 | dw getpixel ;[2E] Get pixel colour at (X,Y) 1502 | dw putpixel ;[30] Set pixel colour at (X,Y) 1503 | dw bitmaputil ;[32] Pointer to bitmap routines 1504 | dw savebitmap ;[34] BITBLT from screen to buffer 1505 | dw restorebitmap ;[36] BITBLT from buffer to screen 1506 | dw setclip ;[38] Set clipping rectangle 1507 | dw colourquery ;[3A] Colour table query 1508 | 1509 | dw 8 dup(NotImpNear) ;Reserved for future use. 1510 | 1511 | ;--------------------------------------------------------------------- 1512 | ;; Indexed call table of functions used by emulated circle/ellipse routines 1513 | BitmapTable dw NotImpFar ;GotoGraphic 1514 | dw NotImpFar ;ExitGraphic 1515 | dw putpixel ;PutPixel 1516 | dw getpixel ;Getpixel 1517 | dw bits_per_pix ;Getpixbyte 1518 | dw setdrawpage ;Set_draw_page 1519 | dw setvispage ;Set_visual_page 1520 | dw setwritemode ;Set_write_mode 1521 | 1522 | ;------- For generic VGA 1523 | Stat0 Status<,,319,319,319,319,,,14000,,,> ;;320x320x2 1524 | Mode0 db 25,"Tweaked Text 320x320 mono", 0 1525 | 1526 | ;; Table of structures 1527 | StatTable dw Stat0 1528 | 1529 | ;; Table of mode names 1530 | ModeNameTable dw Mode0 1531 | 1532 | VidMem dw 0B800h ;; Offset of video memory 1533 | FontMem dw 0A000h 1534 | 1535 | colourtable db 0h ;; Zero-length colour table 1536 | 1537 | cp_x dw ? ;; Current drawing position 1538 | cp_y dw ? 1539 | 1540 | curr_mode db ? ;; Current video mode 1541 | xsiz dw ? ;; Current mode width in pixels 1542 | xbytes dw ? 1543 | ysiz dw ? ;; Current mode height in pixels 1544 | 1545 | bar_xsiz dw ? ;; Patterned bar & BITBLT variables 1546 | next_row dw ? 1547 | 1548 | fill_bits db ?,?,?,?,? 1549 | writemode dw ? 1550 | bltmode db ? 1551 | Logical db 00h,018h,010h,008h 1552 | db 00h,018h,010h,008h,00h 1553 | 1554 | textxsiz dw 8 ;; Text parameters 1555 | textysiz dw TEXTBYTES 1556 | textinc dw 1 1557 | textdir db 0 1558 | textseg dw ? ;; Far pointer to character table 1559 | textofs dw ? 1560 | 1561 | clip_x1 dw ? ;; Clipping rectangle borders 1562 | clip_y1 dw ? 1563 | clip_x2 dw ? 1564 | clip_y2 dw ? 1565 | 1566 | BrdrClr db ? ;; Floodfill variables 1567 | Xvals dw MAXSTACK dup(0) 1568 | Yvals dw MAXSTACK dup(0) 1569 | StkPtr dw ? 1570 | PrevXR dw ? 1571 | CurrXR dw ? 1572 | FillD dw ? 1573 | 1574 | deldx dw ? ;; Line drawing variables 1575 | delsx dw ? 1576 | deldy dw ? 1577 | delsy dw ? 1578 | delde dw ? 1579 | delse dw ? 1580 | 1581 | linecolour db ? ;; Line parameters 1582 | curr_linestyle dw 0ffffh 1583 | linestyles dw 0ffffh ;; Solid Line 1584 | dw 0cccch ;; Dotted Line 1585 | dw 0fc78h ;; Center Line 1586 | dw 0f8f8h ;; Dashed Line 1587 | 1588 | fillpatnum db ? ;; Fill parameters 1589 | fillcolour db ? 1590 | 1591 | fill_lmask db ? 1592 | fill_rmask db ? 1593 | fill_bit db ? 1594 | 1595 | curr_fillpat db ?,?,?,?,?,?,?,? 1596 | fillpatterns db 0ffh,0ffh,000h,000h,0ffh,0ffh,000h,000h ;; Line Fill 1597 | db 001h,002h,004h,008h,010h,020h,040h,080h ;; Lt Slash Fill 1598 | db 0e0h,0c1h,083h,007h,00eh,01ch,038h,070h ;; Slash Fill 1599 | db 0f0h,078h,03ch,01eh,00fh,087h,0c3h,0e1h ;; Backslash Fill 1600 | db 0a5h,0d2h,069h,0b4h,05ah,02dh,096h,04bh ;; Lt Backslash Fill 1601 | db 0ffh,088h,088h,088h,0ffh,088h,088h,088h ;; Hatch Fill 1602 | db 081h,042h,024h,018h,018h,024h,042h,081h ;; XHatch fill 1603 | db 0cch,033h,0cch,033h,0cch,033h,0cch,033h ;; Interleave Fill 1604 | db 080h,000h,008h,000h,080h,000h,008h,000h ;; Wide Dot Fill 1605 | db 088h,000h,022h,000h,088h,000h,022h,000h ;; Close Dot Fill 1606 | 1607 | PageSize dw 04000h,0,0,0,0,0,05000h 1608 | PageOfs dw ? 1609 | 1610 | IF BGIVERSION GE 3 1611 | _DATA ENDS 1612 | ENDIF 1613 | 1614 | end 1615 |  1616 | -------------------------------------------------------------------------------- /SOURCE/TWK256.ASM: -------------------------------------------------------------------------------- 1 | ;; Tweaked 256 Colour BGI Driver Source 2 | ;; 3 | ;; Version: $Revision: 1.15 $ 4 | ;; 5 | ;; Copyright (c) 1991-94, Jordan Hargrave 6 | ;; All rights reserved 7 | ;; 8 | ;; This is Copyrighted software. 9 | ;; Permission is hereby granted to use this source code for 10 | ;; private use only. It may NOT be distributed without permission 11 | ;; of the author. 12 | ;; 13 | ;; If you have any comments about changes or improvements in this code, 14 | ;; please let me know. 15 | ;; 16 | ;; Revision history: 17 | ;; ----------------- 18 | ;; $Log: C:/svga/rcs/twk256.asv $ 19 | ; 20 | ; Rev 1.15 23 Aug 1994 0:05:44 JORDAN 21 | ; 22 | ; Rev 1.14 20 Jul 1994 22:09:28 JORDAN 23 | ; Added support for HGXMOUSE driver. 24 | ; 25 | ; Rev 1.13 09 Jun 1994 23:48:36 JORDAN 26 | ; 27 | ; Rev 1.12 14 May 1994 19:36:08 JORDAN 28 | ;; 29 | .186 30 | 31 | IFNDEF BGIVERSION 32 | BGIVERSION EQU 2 ;; BGI revision version 33 | ;; 2 for most BC/TC and BP/TP 34 | ;; 3 for BP7.0 protected mode 35 | ENDIF 36 | MaxMode EQU 9 ; Maximum mode supported 37 | ;; Change here for font used: 38 | ;; 8 = 8x8 font 39 | ;; 14 = 8x14 font 40 | ;; 16 = 8x16 font 41 | TEXTBYTES EQU 8 42 | 43 | INCLUDE common.inc ; Common defines 44 | 45 | IF BGIVERSION LT 3 46 | 47 | .model SMALL 48 | .CODE 49 | 50 | assume cs:_TEXT,ds:_TEXT,ss:_TEXT 51 | 52 | ;; BGI v2.0 entry code 53 | BGI20Entry 54 | 55 | ELSE 56 | 57 | _TEXT SEGMENT PARA PUBLIC 'CODE' 58 | 59 | assume cs:_TEXT, ds:_DATA 60 | 61 | ;; BGI v3.0 entry code 62 | BGI30Entry 63 | 64 | ENDIF 65 | 66 | ;; EMULATE - Far call to emulation routines in BGI kernel 67 | ;; This area is updated by GRAPH at loadtime 68 | EMULATE: ret 69 | dw 0,0 70 | 71 | ;; Dummy routines for unimplemented procedures 72 | ;; Near return 73 | NotImpNear proc near 74 | ret 75 | NotImpNear endp 76 | 77 | ;; Far return 78 | NotImpFar proc far 79 | ret 80 | NotImpFar endp 81 | 82 | INCLUDE macros.inc 83 | 84 | ;; Restregs - restore default register values 85 | restregs: mov dx,GC_INDEX 86 | mov ax,3 87 | out dx,ax 88 | ret 89 | 90 | ;-------------------------------------------------------------------- 91 | ;;INSTALL - Installs the driver 92 | 93 | install: cmp al,1 94 | jnz notmodequery 95 | mov cx,MaxMode ;; Return # of modes 96 | ret 97 | notmodequery: cmp cl,MaxMode-1 98 | jle TopMode 99 | mov cl,MaxMode-1 100 | TopMode: LoadDataSeg es 101 | xor ch,ch 102 | mov si,cx 103 | shl si,1 104 | test al,al 105 | jz notmodename 106 | mov bx,[si+ModeNameTable] ;; Return mode name 107 | ret 108 | notmodename: mov curr_mode,cl 109 | push es 110 | mov ax,01130h ;; Load pointer to the ROM 111 | if TEXTBYTES EQ 14 112 | mov bh,2 ;; 8x14 font 113 | ENDIF 114 | if TEXTBYTES EQ 16 115 | mov bh,6 ;; 8x16 font 116 | ENDIF 117 | if TEXTBYTES EQ 8 118 | mov bh,3 ;; 8x8 font 119 | ENDIF 120 | int 10h 121 | mov textofs,bp 122 | IF BGIVERSION GE 3 123 | mov es,SEGC000 ;; Evil hack... Couldn't get DPMI 124 | ;; to make the actual segment readable 125 | ENDIF 126 | mov textseg,es 127 | pop es 128 | mov bx,[StatTable+si] ;; Get address of DIT 129 | mov ax,[bx+yefres] 130 | mov ysiz,ax 131 | mov ax,[bx+xefres] 132 | inc ax 133 | mov xsiz,ax 134 | shr ax,1 135 | shr ax,1 136 | mov xbytes,ax 137 | 138 | call setPageSize 139 | InstallOk: ret 140 | 141 | ;; Calculates the size of each video page for this mode 142 | setPageSize: mov ax, xbytes 143 | mul ysiz ;; DX:AX = bytesPerLine*yres 144 | 145 | ;; Round to next 8k 146 | add ax, 01fffh 147 | and ax, 0e000h 148 | cmp ax, 02000h 149 | jz donePageSize 150 | 151 | ;; Round to next 16k 152 | add ax, 03fffh 153 | and ax, 0c000h 154 | cmp ax, 04000h 155 | jz donePageSize 156 | 157 | ;; Round to next 32k 158 | add ax, 07fffh 159 | and ax, 08000h 160 | cmp ax, 08000h 161 | jz donePageSize 162 | 163 | ;; Round to next 64k 164 | add ax, 0ffffh 165 | xor ax, ax 166 | 167 | donePageSize: mov [PageSize], ax 168 | ret 169 | 170 | ;--------------------------------------------------------------------- 171 | ;;INIT - Changes into graphics mode 172 | ;; ES:BX=Device Information Table 173 | 174 | init: 175 | IF BGIVERSION GE 3 176 | mov ax, SEGA000 177 | mov VidMem, ax 178 | ENDIF 179 | mov bl,curr_mode 180 | xor bh,bh 181 | shl bx,1 182 | mov si,TweakModes[bx] 183 | mov ax,013h ;;If so, start with 256-colors 184 | int 010h 185 | 186 | ;; Set vertical retrace 187 | rdinx CRTC_INDEX, 011h 188 | and al, 07fh 189 | wrinx dx, 011h, al 190 | 191 | ;; Initialize registers 192 | xor bx, bx 193 | initLoop: mov dx, InitPorts[bx] 194 | mov ax, [bx+si] 195 | cmp dx, 0ffffh 196 | jz initEnd 197 | call registerOut 198 | add bx, 2 199 | jmp short initLoop 200 | initEnd: 201 | 202 | ;; Enable display 203 | outpw ATTR_INDEX, 020h 204 | 205 | ;; Clear video memory 206 | push es 207 | mov es,VidMem 208 | xor di,di 209 | xor ax, ax 210 | mov cx,08000h 211 | cld 212 | repz stosw 213 | pop es 214 | 215 | ;; Enable HGXMOUSE driver 216 | Enable_Mouse MODE_PL8 217 | ret 218 | 219 | ;; Output value to special registers 220 | registerOut: cmp dx, MISC_OUTPUT 221 | jnz @seqPort 222 | out dx, al 223 | ret 224 | @seqPort: cmp dx, SC_INDEX 225 | jnz @attrPut 226 | cmp al, 01h 227 | jnz @attrPut 228 | push ax 229 | outpw dx, 0100h 230 | pop ax 231 | out dx, ax 232 | outpw dx, 0300h 233 | ret 234 | @attrPut: cmp dx, ATTR_INDEX 235 | jnz @normalPut 236 | push ax 237 | inp 03dah 238 | pop ax 239 | outp ATTR_INDEX, al 240 | outp dx, ah 241 | ret 242 | @normalPut: outpw dx, ax 243 | ret 244 | 245 | ;--------------------------------------------------------------------- 246 | ;;POST - Exit from graphics mode 247 | 248 | post: Disable_Mouse 249 | ret 250 | 251 | ;--------------------------------------------------------------------- 252 | ;;CLEAR - Clears the screen 253 | 254 | clear: mov dx,SC_INDEX 255 | mov es,VidMem 256 | mov al,MAP_MASK 257 | mov ah,008h 258 | clrlp: out dx,ax 259 | mov di, [PageOfs] 260 | mov cx, [PageSize] 261 | shr cx, 1 262 | push ax 263 | xor ax,ax 264 | repz stosw 265 | pop ax 266 | shr ah,1 267 | jnz clrlp 268 | ret 269 | 270 | ;--------------------------------------------------------------------- 271 | ;;MOVE - Moves the current draw pointer to X,Y 272 | ;; AX=New X coordinate 273 | ;; BX=New Y coordinate 274 | 275 | move: mov cp_x,ax 276 | mov cp_y,bx 277 | ret 278 | 279 | ;--------------------------------------------------------------------- 280 | ;;DRAW - Draws line from CP to X,Y 281 | ;; AX=End X coordinate 282 | ;; BX=End Y coordinate 283 | 284 | draw: mov cx,cp_x 285 | mov dx,cp_y 286 | mov cp_x,ax ;; Update drawing pointer 287 | mov cp_y,bx 288 | 289 | ;--------------------------------------------------------------------- 290 | ;;VECT - Draws line from X1,Y1 to X2,Y2 291 | ;; AX=Start X coordinate 292 | ;; BX=Start Y coordinate 293 | ;; CX=End X coordinate 294 | ;; DX=End Y coordinate 295 | ;; 296 | ;; Bresenhams ine drawing algorithm from Bluebook of Assembly Routines for 297 | ;; the IBM PC & XT, with minor modifications :jph 298 | 299 | vect: cmp ax,cx ;;Make sure x coord increases 300 | jle vctok 301 | xchg ax,cx 302 | xchg bx,dx 303 | vctok: mov es,VidMem 304 | xor si,si ;; X increment 305 | mov di,xbytes ;; Y increment 306 | 307 | sub cx,ax ;; Check if X2 xr 818 | jg @ScnRgtSExit 819 | mov ax,si ;; TstPix 820 | mov bx,[bp+8] 821 | call getpixel 822 | cmp dl,BrdrClr 823 | je @ScnRgtS00 824 | mov ax,si ;; return x 825 | jmp short @ScnRgtS02 826 | @ScnRgtSExit: mov ax,-1 ;; return -1 827 | @ScnRgtS02: pop si 828 | pop di 829 | pop bp 830 | ret 831 | 832 | ;--------------------------------------------------------------------------- 833 | ;;FillHoriz - Fills a horizontal line 834 | 835 | FillHoriz: push bp 836 | mov bp,sp 837 | push di 838 | push si 839 | mov si,[bp+4] ; x 840 | mov di,[bp+6] ; y 841 | mov ax,CurrXR 842 | mov PrevXR,ax 843 | push di 844 | push si 845 | call ScanRight 846 | add sp,4 847 | mov CurrXR,ax ; Xr 848 | mov cx,si 849 | mov dx,di ; Y 850 | mov bx,di ; Y 851 | call patbar 852 | pop si 853 | pop di 854 | pop bp 855 | ret 856 | 857 | ;--------------------------------------------------------------------------- 858 | ;;ScanLine - Scans a line, adding entries to the fill stack 859 | 860 | ScanLine: push bp 861 | mov bp,sp 862 | push di 863 | push si 864 | mov si,[bp+4] ; xl 865 | mov di,[bp+6] ; xr 866 | jmp short @ScnLin02 867 | @ScnLin00: mov bx,StkPtr 868 | shl bx,1 869 | mov ax,si 870 | cmp word ptr [bp+10],0 ; dir 871 | jge @ScnLin01 872 | not ax 873 | @ScnLin01: mov Xvals[bx],ax ;; Add left x coord to stack 874 | mov ax,[bp+8] ; y 875 | mov Yvals[bx],ax ;; Add y coord to stack 876 | inc StkPtr ;; Increase stack pointer 877 | push ax 878 | push si 879 | call ScanRight 880 | add sp,4 881 | mov si,ax 882 | inc si 883 | @ScnLin02: push [bp+8] ; y 884 | push di 885 | push si 886 | call ScanRightS 887 | add sp,6 888 | mov si,ax 889 | test si,si 890 | jl @ScnLinExit 891 | cmp StkPtr,MaxStack 892 | jne @ScnLin00 893 | mov ax,-1 894 | jmp short @ScnLin03 895 | @ScnLinExit: sub ax,ax 896 | @ScnLin03: pop si 897 | pop di 898 | pop bp 899 | ret 900 | 901 | ;--------------------------------------------------------------------------- 902 | ;;ChkStk - Checks if a coord is in the fill stack 903 | 904 | ChkStk: push bp 905 | mov bp,sp 906 | push di 907 | push si 908 | mov si,[bp+4] ; x 909 | sub di,di 910 | cmp [bp+8],di ; dir 911 | jge @ChkStk00 912 | not si 913 | @ChkStk00: mov dx,[bp+6] ; y 914 | mov cx,StkPtr 915 | jmp short @ChkStk04 916 | @ChkStk01: mov bx,di 917 | shl bx,1 918 | mov ax,Xvals[bx] ;; Remove duplicate entry 919 | mov Xvals[bx-2],ax 920 | mov ax,Yvals[bx] 921 | mov Yvals[bx-2],ax 922 | @ChkStk02: inc di 923 | cmp di,cx 924 | jl @ChkStk01 925 | dec cx ; Decrease stack pointer 926 | mov ax,1 ; return 1 927 | jmp short @ChkStk05 928 | @ChkStk03: inc di 929 | @ChkStk04: cmp cx,di 930 | jle @ChkStkExit 931 | mov bx,di 932 | shl bx,1 933 | cmp Xvals[bx],si ; Compare x with stack 934 | jne @ChkStk03 935 | cmp Yvals[bx],dx ; Compare y with stack 936 | jne @ChkStk03 937 | jmp short @ChkStk02 938 | @ChkStkExit: sub ax,ax ; return 0 939 | @ChkStk05: mov StkPtr,cx 940 | pop si 941 | pop di 942 | pop bp 943 | ret 944 | 945 | ;--------------------------------------------------------------------------- 946 | ;;ScanUpDn - Scans up or down until a boundary is reached 947 | 948 | ScanUpDn: push bp 949 | mov bp,sp 950 | sub sp,18 951 | push di 952 | push si 953 | mov ax,[bp+8] ;Dir 954 | neg ax 955 | mov [bp-18],ax 956 | @ScnUpDn00: mov ax,[bp+6] ;Yc 957 | add ax,[bp+8] ;Dir 958 | mov [bp-6],ax ;CurrY 959 | mov ax,clip_y1 960 | cmp [bp-6],ax ;CurrY 961 | jl @ScnUpDn01 962 | mov ax,clip_y2 963 | cmp [bp-6],ax ;CurrY 964 | jle @ScnUpDn02 965 | @ScnUpDn01: sub ax,ax 966 | jmp @ScnUpDnExit 967 | @ScnUpDn02: mov ax,[bp+4] ;Xc 968 | mov [bp-4],ax ;PrevXL 969 | mov bx,[bp-6] ;; TstPix 970 | call getpixel 971 | cmp dl,BrdrClr 972 | je @ScnUpDn03 973 | push [bp-6] ;CurrY 974 | push [bp+4] ;Xc 975 | call ScanLeft 976 | add sp,4 977 | mov [bp-2],ax ;CurrXL 978 | jmp short @ScnUpDn04 979 | @ScnUpDn03: push [bp-6] ;CurrY 980 | push CurrXR 981 | push [bp+4] ;Xc 982 | call ScanRightS 983 | add sp,6 984 | mov [bp-2],ax ;CurrXL 985 | test ax,ax 986 | jl @ScnUpDn01 987 | @ScnUpDn04: push [bp-6] ;CurrY 988 | push [bp-2] ;CurrXL 989 | call FillHoriz 990 | add sp,4 991 | mov ax,[bp-4] ;PrevXL 992 | cmp [bp-2],ax ;CurrXL 993 | jge @ScnUpDn10 994 | mov si,[bp-2] ;CurrXL 995 | push [bp+6] ;Yc 996 | push si 997 | call ScanLeft 998 | add sp,4 999 | mov di,ax 1000 | cmp di,si 1001 | jge @ScnUpDn08 1002 | jmp short @ScnUpDn06 1003 | @ScnUpDn05: mov si,di 1004 | push [bp+6] ;Yc 1005 | push si 1006 | call ScanLeft 1007 | add sp,4 1008 | mov di,ax 1009 | @ScnUpDn06: cmp di,si 1010 | jge @ScnUpDn07 1011 | mov si,di 1012 | push [bp-6] ;CurrY 1013 | push si 1014 | call ScanLeft 1015 | add sp,4 1016 | mov di,ax 1017 | cmp di,si 1018 | jl @ScnUpDn05 1019 | @ScnUpDn07: push [bp+8] ;Dir 1020 | push [bp-6] ;CurrY 1021 | mov ax,[bp-2] ;CurrXL 1022 | dec ax 1023 | push ax 1024 | push si 1025 | call ScanLine 1026 | add sp,8 1027 | test ax,ax 1028 | jne @ScnUpDn09 1029 | @ScnUpDn08: push [bp-18] 1030 | push [bp+6] ;Yc 1031 | mov ax,[bp-4] ;PrevXL 1032 | dec ax 1033 | push ax 1034 | push si 1035 | call ScanLine 1036 | add sp,8 1037 | test ax,ax 1038 | je @ScnUpDn10 1039 | @ScnUpDn09: mov ax,-1 1040 | @ScnUpDnExit: pop si 1041 | pop di 1042 | mov sp,bp 1043 | pop bp 1044 | ret 1045 | @ScnUpDn10: mov ax,CurrXR 1046 | cmp PrevXR,ax 1047 | jne @ScnUpDn11 1048 | jmp @ScnUpDn17 1049 | @ScnUpDn11: mov ax,[bp+8] ;Dir 1050 | mov [bp-8],ax ;FillD 1051 | mov ax,CurrXR 1052 | mov [bp-4],ax ;PrevXL 1053 | mov ax,PrevXR 1054 | mov [bp-14],ax ;NewXL 1055 | mov ax,CurrXR 1056 | cmp PrevXR,ax 1057 | jle @ScnUpDn12 1058 | mov ax,[bp-14] ;NewXL 1059 | xchg ax,[bp-4] ;PrevXL 1060 | mov [bp-14],ax 1061 | mov ax,[bp-6] ;CurrY 1062 | mov [bp+6],ax ;Yc 1063 | mov ax,[bp-8] ;FillD 1064 | neg ax 1065 | mov [bp-8],ax ;FillD 1066 | @ScnUpDn12: mov si,[bp-4] ;PrevXL 1067 | push [bp+6] ;Yc 1068 | push si 1069 | call ScanRight 1070 | add sp,4 1071 | mov di,ax 1072 | cmp di,si 1073 | jle @ScnUpDn16 1074 | jle @ScnUpDn14 1075 | mov ax,[bp+6] ;Yc 1076 | add ax,[bp-8] ;FillD 1077 | mov [bp-16],ax 1078 | @ScnUpDn13: mov si,di 1079 | push [bp-16] 1080 | push si 1081 | call ScanRight 1082 | add sp,4 1083 | mov di,ax 1084 | cmp di,si 1085 | jg @ScnUpDn15 1086 | @ScnUpDn14: push [bp-8] ;FillD 1087 | mov ax,[bp+6] ;Yc 1088 | add ax,[bp-8] ;FillD 1089 | push ax 1090 | push si 1091 | mov ax,[bp-4] ;PrevXL 1092 | inc ax 1093 | push ax 1094 | call ScanLine 1095 | add sp,8 1096 | test ax,ax 1097 | je @ScnUpDn16 1098 | jmp @ScnUpDn09 1099 | @ScnUpDn15: mov si,di 1100 | push [bp+6] ;Yc 1101 | push si 1102 | call ScanRight 1103 | add sp,4 1104 | mov di,ax 1105 | cmp di,si 1106 | jle @ScnUpDn14 1107 | jmp short @ScnUpDn13 1108 | @ScnUpDn16: mov ax,[bp-8] ;FillD 1109 | neg ax 1110 | push ax 1111 | push [bp+6] ;Yc 1112 | push si 1113 | mov ax,[bp-14] ;NewXL 1114 | inc ax 1115 | push ax 1116 | call ScanLine 1117 | add sp,8 1118 | test ax,ax 1119 | je @ScnUpDn17 1120 | jmp @ScnUpDn09 1121 | @ScnUpDn17: mov ax,[bp-2] ;CurrXL 1122 | mov [bp+4],ax ;Xc 1123 | mov ax,[bp-6] ;CurrY 1124 | mov [bp+6],ax ;Yc 1125 | push [bp-18] 1126 | push ax 1127 | push [bp+4] ;Xc 1128 | call ChkStk 1129 | add sp,6 1130 | test ax,ax 1131 | jne @ScnUpDn18 1132 | jmp @ScnUpDn00 1133 | @ScnUpDn18: jmp @ScnUpDn01 1134 | 1135 | ;--------------------------------------------------------------------- 1136 | ;;FLOODFILL - Fills a bounded region with a pattern 1137 | ;; AX=X coordinate of the seed point 1138 | ;; BX=Y coordinate of the seed point 1139 | ;; CL=Boundary colour for fill 1140 | 1141 | FloodFill: mov word ptr FillD,-1 1142 | mov BrdrClr,cl 1143 | mov si,ax ;; SeedX 1144 | mov di,bx ;; SeedY 1145 | call getpixel ;; TstPix 1146 | cmp dl,BrdrClr 1147 | jne @FldFill_00 1148 | jmp short @FldFill_Exit 1149 | @FldFill_00: push di ;; SeedY 1150 | push si ;; SeedX 1151 | call ScanLeft 1152 | add sp,4 1153 | mov si,ax ;; SeedX 1154 | mov Xvals,ax 1155 | mov Yvals,di ;; SeedY 1156 | mov StkPtr,1 1157 | push di ;; SeedY 1158 | push si ;; SeedX 1159 | call ScanRight 1160 | add sp,4 1161 | mov CurrXR,ax 1162 | jmp short @FldFill_03 1163 | @FldFill_01: mov bx,StkPtr 1164 | test bx,bx 1165 | je @FldFill_Exit 1166 | dec bx 1167 | mov StkPtr,bx 1168 | shl bx,1 1169 | mov si,Xvals[bx] 1170 | mov di,Yvals[bx] 1171 | mov ax,1 1172 | test si,si 1173 | jge @FldFill_02 1174 | not si 1175 | neg ax 1176 | @FldFill_02: mov FillD,ax 1177 | push di 1178 | push si 1179 | call FillHoriz 1180 | add sp,4 1181 | mov ax,FillD 1182 | neg ax 1183 | push ax 1184 | push di 1185 | push si 1186 | call ChkStk 1187 | add sp,6 1188 | test ax,ax 1189 | jne @FldFill_01 1190 | @FldFill_03: push FillD 1191 | push di 1192 | push si 1193 | call ScanUpDn 1194 | add sp,6 1195 | test ax,ax 1196 | je @FldFill_01 1197 | @FldFill_Exit: ret 1198 | 1199 | ;--------------------------------------------------------------------- 1200 | ;;GETPIXEL - Reads a pixel from the screen 1201 | ;; AX=X coordinate of the seed point 1202 | ;; BX=Y coordinate of the seed point 1203 | ;; 1204 | ;; Code from John Bridges' VGAKIT 1205 | 1206 | getpixel: mov cx,ax 1207 | xchg ax,bx 1208 | shr bx,1 1209 | shr bx,1 1210 | mul xbytes ;; Calculate offset of pixel 1211 | add bx,ax 1212 | add bx,[PageOfs] 1213 | 1214 | and cl,3 1215 | mov ah,cl 1216 | mov al,READ_MAP 1217 | mov dx,GC_INDEX 1218 | out dx,ax 1219 | mov es,VidMem 1220 | xor dx,dx 1221 | mov dl,es:[bx] ;; Read pixel colour 1222 | ret 1223 | 1224 | ;--------------------------------------------------------------------- 1225 | ;;PUTPIXEL - Writes a pixel to the screen 1226 | ;; AX=X coordinate of the seed point 1227 | ;; BX=Y coordinate of the seed point 1228 | ;; DL=colour of the seed point 1229 | ;; 1230 | ;; Code from John Bridges' VGAKIT 1231 | 1232 | putpixel: push dx 1233 | xchg ax,bx 1234 | mov cx,bx 1235 | shr bx,1 1236 | shr bx,1 1237 | mul xbytes ;; Calculate offset of pixel 1238 | add bx,ax 1239 | add bx,[PageOfs] 1240 | 1241 | and cl,3 1242 | mov ah,1 1243 | shl ah,cl 1244 | mov al,MAP_MASK 1245 | mov dx,SC_INDEX 1246 | out dx,ax 1247 | pop dx 1248 | mov es,VidMem 1249 | mov es:[bx],dl ;; Store Pixel 1250 | ret 1251 | 1252 | ;--------------------------------------------------------------------- 1253 | ;;BITMAPUTIL - Returns pointer to bitmap routines 1254 | bitmaputil: LoadDataSeg es 1255 | mov bx,offset BitmapTable 1256 | ret 1257 | 1258 | ;--------------------------------------------------------------------- 1259 | ;;BITBLT from screen to buffer 1260 | ;; ES:BX=memory buffer to store image in 1261 | ;; ES:[BX+0]=(Width of rectangle - 1) 1262 | ;; ES:[BX+2]=(Height of rectangle - 1) 1263 | ;; CX=Upper left X coordinate 1264 | ;; DX=Upper left Y coordinate 1265 | 1266 | savebitmap: mov ax,es:[bx] ;; Width of image-1 1267 | inc ax 1268 | mov bar_xsiz,ax 1269 | 1270 | mov ax,dx ;; Calculate offset of first row 1271 | mov di,cx 1272 | shr di,1 1273 | shr di,1 1274 | mul xbytes 1275 | add di,ax 1276 | add di,[PageOfs] 1277 | and cl,3 1278 | mov ah,cl 1279 | mov si,es:[bx+2] ;; Height of image-1 1280 | add bx,4 1281 | 1282 | mov dx,GC_INDEX 1283 | GetLoopY: mov cx,bar_xsiz 1284 | push ax 1285 | push di 1286 | GetLoopX: mov al,READ_MAP 1287 | out dx,ax 1288 | push es 1289 | mov es,VidMem 1290 | mov al,es:[di] ;; Get pixel from screen 1291 | pop es 1292 | mov es:[bx],al ;; Store pixel in buffer 1293 | 1294 | add bx,1 ;; Check for >64k access 1295 | jnz NIseg 1296 | push ax 1297 | mov ax,es 1298 | add ax,01000h 1299 | mov es,ax 1300 | cmp ax,09000h ;; Check for end of memory 1301 | pop ax 1302 | ja GetExit 1303 | NIseg: inc ah 1304 | cmp ah,4 1305 | jnz noGetBk 1306 | inc di 1307 | xor ah,ah 1308 | noGetBk: loop GetLoopX 1309 | pop di 1310 | add di,xbytes ;; Increment offset to next row 1311 | pop ax 1312 | dec si ;; Decrease y counter 1313 | jns GetLoopY 1314 | GetExit: ret 1315 | 1316 | ;--------------------------------------------------------------------- 1317 | ;;BITBLT from buffer to screen 1318 | ;; ES:BX=memory buffer with stored image 1319 | ;; ES:[BX+0]=(Width of rectangle - 1) 1320 | ;; ES:[BX+2]=(Height of rectangle - 1) 1321 | ;; CX=Upper left X coordinate 1322 | ;; DX=Upper left Y coordinate 1323 | ;; AL=Logical restore operation 1324 | ;; 0 - COPY_PUT 4 - NOT_PUT 8 - TRANS_COPY_PUT 1325 | ;; 1 - XOR_PUT 5 - XNOR_PUT 1326 | ;; 2 - OR_PUT 6 - NOR_PUT 1327 | ;; 3 - AND_PUT 7 - NAND_PUT 1328 | 1329 | restorebitmap: mov bltmode,al 1330 | xor ah,ah 1331 | mov si,ax 1332 | mov ah,Logical[si] 1333 | push dx ;; Set pixel update fn 1334 | mov dx,GC_INDEX 1335 | mov al,3 1336 | out dx,ax 1337 | pop dx 1338 | mov si,es:[bx] ;; Width of image-1 1339 | inc si 1340 | mov bar_xsiz,si 1341 | 1342 | mov ax,dx ;; Calculate offset of first row 1343 | mov di,cx 1344 | shr di,1 1345 | shr di,1 1346 | mul xbytes 1347 | add di,[PageOfs] 1348 | add di,ax 1349 | and cl,3 1350 | mov ah,011h 1351 | rol ah,cl 1352 | mov si,es:[bx+2] ;; Height of image-1 1353 | add bx,4 1354 | 1355 | mov dx,SC_INDEX 1356 | PutLoopY: mov cx,bar_xsiz 1357 | push ax 1358 | push di 1359 | PutLoopX: mov al,MAP_MASK 1360 | out dx,ax 1361 | mov al,es:[bx] ;; Get pixel out of buffer 1362 | push es 1363 | mov es,VidMem 1364 | cmp bltmode,8 ;; TRANS_COPY_PIX 1365 | jnz notTCP 1366 | test al,al ;; If color 0, don't plot 1367 | jnz doPUT 1368 | jmp short noPUT 1369 | notTCP: cmp bltmode,4 ;; Check for NOR, NXOR, etc.. 1370 | jl doPUT 1371 | not al 1372 | doPUT: xchg es:[di],al ;; Store it! 1373 | noPUT: pop es 1374 | add bx,1 ;; Check for >64k access 1375 | jnz NOseg 1376 | push ax 1377 | mov ax,es 1378 | add ax,01000h 1379 | mov es,ax 1380 | cmp ax,09000h ;; Check for end of memory 1381 | pop ax 1382 | ja PutExit 1383 | NOseg: rol ah,1 1384 | jnc noPutBk 1385 | inc di 1386 | noPutBk: loop PutLoopX 1387 | pop di 1388 | add di,xbytes 1389 | pop ax 1390 | dec si ;; Decrease y counter 1391 | jns PutLoopY 1392 | PutExit: jmp restregs 1393 | 1394 | ;--------------------------------------------------------------------- 1395 | ;; SETCLIP - Sets the clipping rectangle 1396 | ;; AX=Upper left X coordinate 1397 | ;; BX=Upper left Y coordinate 1398 | ;; CX=Lower right X coordinate 1399 | ;; DX=Lower right Y coordinate 1400 | 1401 | setclip: mov clip_x1,ax 1402 | mov clip_y1,bx 1403 | mov clip_x2,cx 1404 | mov clip_y2,dx 1405 | ret 1406 | 1407 | ;--------------------------------------------------------------------- 1408 | ;; COLOURQUERY - colour & palette info 1409 | 1410 | ;; Get length of colour table & number of colours available 1411 | colourquery: test al,al 1412 | jnz clrtable 1413 | xor bx,bx 1414 | mov cx,255 1415 | ret 1416 | 1417 | ;; Get offset of colour table 1418 | clrtable: LoadDataSeg es 1419 | mov bx,offset colourtable 1420 | ret 1421 | 1422 | ;--------------------------------------------------------------------- 1423 | ; Now for the miscellaneous routines 1424 | 1425 | ;; BITS_PER_PIX - Returns the pixel colour depth 1426 | bits_per_pix proc far 1427 | mov ax,8 1428 | ret 1429 | bits_per_pix endp 1430 | 1431 | ;; SETWRITEMODE - Sets the line drawing mode 1432 | setwritemode proc far 1433 | and ax,1 1434 | push ds 1435 | LoadDataSeg ds 1436 | mov writemode,ax 1437 | pop ds 1438 | ret 1439 | setwritemode endp 1440 | 1441 | ;; getdrawpage - returns 32-bit page offset: 1442 | ;; AX - lower 16 bits 1443 | ;; DX - upper 16 bits 1444 | getdrawpage proc 1445 | xor ah,ah 1446 | mov cx,ax 1447 | xor ax,ax 1448 | xor dx,dx 1449 | jcxz spage_it 1450 | spage1: add ax,[PageSize] 1451 | loop spage1 1452 | spage_it: ret 1453 | getdrawpage endp 1454 | 1455 | ;; SETVISPAGE - Sets the visible video page 1456 | setvispage proc far 1457 | push cx 1458 | push ds 1459 | LoadDataSeg ds 1460 | 1461 | ;; Get address of drawing page 1462 | call getdrawpage 1463 | 1464 | mov bh, al 1465 | mov bl, 0dh 1466 | mov ch, ah 1467 | mov cl, 0ch 1468 | 1469 | cli 1470 | WaitForEnable 1471 | 1472 | ;; Set display start address 1473 | outpw CRTC_INDEX, bx 1474 | outpw dx, cx 1475 | 1476 | WaitForRetrace 1477 | sti 1478 | 1479 | pop ds 1480 | pop cx 1481 | ret 1482 | setvispage endp 1483 | 1484 | ;; SETDRAWPAGE - Sets the drawing video page 1485 | setdrawpage proc far 1486 | push cx 1487 | push ds 1488 | LoadDataSeg ds 1489 | call getdrawpage 1490 | mov [PageOfs], ax 1491 | pop ds 1492 | pop cx 1493 | ret 1494 | setdrawpage endp 1495 | 1496 | IF BGIVERSION GE 3 1497 | _TEXT ENDS 1498 | 1499 | _DATA SEGMENT PARA PUBLIC 'DATA' 1500 | 1501 | assume ds:_DATA, cs:Nothing 1502 | 1503 | InitTable EQU $ 1504 | NRealSegs db 4 1505 | RealSegOfs dw SegTable 1506 | NIntVects db 1 1507 | IntVecOfs dw VectTable 1508 | NRealBlocks db 0 1509 | RealBlockOfs dw 0 1510 | DSinRealMem db 1 1511 | RealModeDS dw 0 1512 | CurOpMode db 0 1513 | 1514 | SegTable EQU $ 1515 | SEG0040 dw 00040h 1516 | SEGA000 dw 0A000h 1517 | SEGC000 dw 0C000h 1518 | SEGF000 dw 0F000h 1519 | 1520 | VectTable EQU $ 1521 | ChrGen dd 0000001fh 1522 | 1523 | ENDIF 1524 | 1525 | ;;Indexed call table of BGI routines 1526 | DDOVEC dw install ;[00] Install the driver 1527 | dw init ;[02] Initialize the driver 1528 | dw clear ;[04] Clear the graphics device 1529 | dw post ;[06] Exit from graphics mode 1530 | dw move ;[08] Move current pointer 1531 | dw draw ;[0A] Draw line from CP to X,Y 1532 | dw vect ;[0C] Draw line from X1,Y1 to X2,Y2 1533 | dw EMULATE ;[0E] Reserved 1534 | dw EMULATE ;[10] Filled 3d bar {emulated} 1535 | dw patbar ;[12] Patterned bar 1536 | dw EMULATE ;[14] Arc {emulated} 1537 | dw EMULATE ;[16] Pieslice {emulated} 1538 | dw EMULATE ;[18] Filled ellipse {emulated} 1539 | dw palette ;[1A] Load a palette entry 1540 | dw NotImpNear ;[1C] Load the full palette 1541 | dw colour ;[1E] Set current line/fill colour 1542 | dw fillstyle ;[20] Set fill pattern 1543 | dw linestyle ;[22] Set line style 1544 | dw textstyle ;[24] Default font control 1545 | dw text ;[26] Default font output at CP 1546 | dw textsize ;[28] Default font size query 1547 | dw EMULATE ;[2A] Reserved 1548 | dw floodfill ;[2C] Fill a bounded region 1549 | dw getpixel ;[2E] Get pixel colour at (X,Y) 1550 | dw putpixel ;[30] Set pixel colour at (X,Y) 1551 | dw bitmaputil ;[32] Pointer to bitmap routines 1552 | dw savebitmap ;[34] BITBLT from screen to buffer 1553 | dw restorebitmap ;[36] BITBLT from buffer to screen 1554 | dw setclip ;[38] Set clipping rectangle 1555 | dw colourquery ;[3A] Colour table query 1556 | 1557 | dw 8 dup(NotImpNear) ;Reserved for future use. 1558 | 1559 | ;--------------------------------------------------------------------- 1560 | ;; Indexed call table of functions used by emulated circle/ellipse routines 1561 | BitmapTable dw NotImpFar ;GotoGraphic 1562 | dw NotImpFar ;ExitGraphic 1563 | dw putpixel ;PutPixel 1564 | dw getpixel ;Getpixel 1565 | dw bits_per_pix ;Getpixbyte 1566 | dw setdrawpage ;Set_draw_page 1567 | dw setvispage ;Set_visual_page 1568 | dw setwritemode ;Set_write_mode 1569 | 1570 | ;------- For generic VGA 1571 | Stat0 Status<,,319,399,319,399,,,16666,,,> ;;320x400x256 (2) 1572 | Mode0 db 23,"VGA Tweaked 320x400x256",0 1573 | Stat1 Status<,,319,479,319,479,,,20000,,,> ;;320x480x256 1574 | Mode1 db 23,"VGA Tweaked 320x480x256",0 1575 | Stat2 Status<,,359,479,359,479,,,17777,,,> ;;360x480x256 1576 | Mode2 db 23,"VGA Tweaked 360x480x256",0 1577 | Stat3 Status<,,375,563,375,563,,,20000,,> ;;376x564x256 1578 | Mode3 db 23,"VGA Tweaked 376x564x256",0 1579 | Stat4 Status<,,399,563,399,563,,,18800,,,> ;;400x564x256 1580 | Mode4 db 23,"VGA Tweaked 400x564x256",0 1581 | Stat5 Status<,,399,599,399,599,,,20000,,,> ;;400x600x256 1582 | Mode5 db 23,"VGA Tweaked 400x600x256",0 1583 | Stat6 Status<,,319,239,319,239,,,10000,,,> ;;320x240x256 (3) 1584 | Mode6 db 23,"VGA Tweaked 320x240x256",0 1585 | Stat7 Status<,,359,349,359,349,,,12000,,,> ;;360x350x256 1586 | Mode7 db 23,"VGA Tweaked 360x350x256",0 1587 | 1588 | ;; Table of structures 1589 | StatTable dw Stat0, Stat1, Stat2, Stat3, Stat4, Stat5, Stat6, Stat7 1590 | 1591 | ;; Table of mode names 1592 | ModeNameTable dw Mode0, Mode1, Mode2, Mode3, Mode4, Mode5, Mode6, Mode7 1593 | 1594 | VidMem dw 0A000h ;; Offset of video memory 1595 | 1596 | colourtable db 0h ;; Zero-length colour table 1597 | 1598 | cp_x dw ? ;; Current drawing position 1599 | cp_y dw ? 1600 | 1601 | curr_mode db ? ;; Current video mode 1602 | xsiz dw ? ;; Current mode width in pixels 1603 | xbytes dw ? 1604 | ysiz dw ? ;; Current mode height in pixels 1605 | 1606 | bar_xsiz dw ? ;; Patterned bar & BITBLT variables 1607 | next_row dw ? 1608 | 1609 | writemode dw ? 1610 | bltmode db ? 1611 | Logical db 00h,018h,010h,008h 1612 | db 00h,018h,010h,008h,00h 1613 | 1614 | textxsiz dw 8 ;; Text parameters 1615 | textysiz dw TEXTBYTES 1616 | textinc dw 1 1617 | textdir db 0 1618 | textseg dw ? ;; Far pointer to character table 1619 | textofs dw ? 1620 | 1621 | clip_x1 dw ? ;; Clipping rectangle borders 1622 | clip_y1 dw ? 1623 | clip_x2 dw ? 1624 | clip_y2 dw ? 1625 | 1626 | BrdrClr db ? ;; Floodfill variables 1627 | Xvals dw MAXSTACK dup(0) 1628 | Yvals dw MAXSTACK dup(0) 1629 | StkPtr dw ? 1630 | PrevXR dw ? 1631 | CurrXR dw ? 1632 | FillD dw ? 1633 | 1634 | deldxy dw ? ;; Line drawing variables 1635 | delsxy dw ? 1636 | delde dw ? 1637 | delse dw ? 1638 | 1639 | linecolour db ? ;; Line parameters 1640 | curr_linestyle dw 0ffffh 1641 | linestyles dw 0ffffh ;; Solid Line 1642 | dw 0cccch ;; Dotted Line 1643 | dw 0fc78h ;; Center Line 1644 | dw 0f8f8h ;; Dashed Line 1645 | 1646 | fillpatnum db ? ;; Fill parameters 1647 | fillcolour db ? 1648 | 1649 | fill_lmask db ? 1650 | fill_rmask db ? 1651 | fill_bit db ? 1652 | 1653 | curr_fillpat db ?,?,?,?,?,?,?,? 1654 | fillpatterns db 0ffh,0ffh,000h,000h,0ffh,0ffh,000h,000h ;; Line Fill 1655 | db 001h,002h,004h,008h,010h,020h,040h,080h ;; Lt Slash Fill 1656 | db 0e0h,0c1h,083h,007h,00eh,01ch,038h,070h ;; Slash Fill 1657 | db 0f0h,078h,03ch,01eh,00fh,087h,0c3h,0e1h ;; Backslash Fill 1658 | db 0a5h,0d2h,069h,0b4h,05ah,02dh,096h,04bh ;; Lt Backslash Fill 1659 | db 0ffh,088h,088h,088h,0ffh,088h,088h,088h ;; Hatch Fill 1660 | db 081h,042h,024h,018h,018h,024h,042h,081h ;; XHatch fill 1661 | db 0cch,033h,0cch,033h,0cch,033h,0cch,033h ;; Interleave Fill 1662 | db 080h,000h,008h,000h,080h,000h,008h,000h ;; Wide Dot Fill 1663 | db 088h,000h,022h,000h,088h,000h,022h,000h ;; Close Dot Fill 1664 | 1665 | ;; Paging information 1666 | PageSize dw ? 1667 | PageOfs dw ? 1668 | 1669 | TweakModes dw x320y400 1670 | dw x320y480 1671 | dw x360y480 1672 | dw x376y564 1673 | dw x400y564 1674 | dw x400y600 1675 | dw x320y240 1676 | dw x360y350 1677 | 1678 | ;; Port list to write 1679 | InitPorts dw MISC_OUTPUT 1680 | dw CRTC_INDEX 1681 | dw CRTC_INDEX 1682 | dw CRTC_INDEX 1683 | dw CRTC_INDEX 1684 | dw CRTC_INDEX 1685 | dw CRTC_INDEX 1686 | dw CRTC_INDEX 1687 | dw CRTC_INDEX 1688 | dw CRTC_INDEX 1689 | dw CRTC_INDEX 1690 | dw CRTC_INDEX 1691 | dw CRTC_INDEX 1692 | dw CRTC_INDEX 1693 | dw CRTC_INDEX 1694 | dw CRTC_INDEX 1695 | dw CRTC_INDEX 1696 | dw CRTC_INDEX 1697 | dw CRTC_INDEX 1698 | dw CRTC_INDEX 1699 | dw SC_INDEX 1700 | dw SC_INDEX 1701 | dw GC_INDEX 1702 | dw GC_INDEX 1703 | dw ATTR_INDEX 1704 | dw ATTR_INDEX 1705 | dw -1 1706 | x320y240 dw 000e3h 1707 | dw 05f00h 1708 | dw 04f01h 1709 | dw 05002h 1710 | dw 08203h 1711 | dw 05404h 1712 | dw 08005h 1713 | dw 00d06h 1714 | dw 03e07h 1715 | dw 00008h 1716 | dw 04109h 1717 | dw 0000fh 1718 | dw 0ea10h 1719 | dw 0ac11h 1720 | dw 0df12h 1721 | dw 02813h 1722 | dw 00014h 1723 | dw 0e715h 1724 | dw 00616h 1725 | dw 0e317h 1726 | dw 00101h 1727 | dw 00604h 1728 | dw 04005h 1729 | dw 00506h 1730 | dw 04110h 1731 | dw 00013h 1732 | x360y480 dw 000e3h 1733 | dw 06b00h 1734 | dw 05901h 1735 | dw 05a02h 1736 | dw 08e03h 1737 | dw 05e04h 1738 | dw 08a05h 1739 | dw 00d06h 1740 | dw 03e07h 1741 | dw 00008h 1742 | dw 04009h 1743 | dw 0000fh 1744 | dw 0ea10h 1745 | dw 0ac11h 1746 | dw 0df12h 1747 | dw 02d13h 1748 | dw 00014h 1749 | dw 0e715h 1750 | dw 00616h 1751 | dw 0e317h 1752 | dw 00101h 1753 | dw 00604h 1754 | dw 04005h 1755 | dw 00506h 1756 | dw 04110h 1757 | dw 00013h 1758 | x320y480 dw 000e3h 1759 | dw 05f00h 1760 | dw 04f01h 1761 | dw 05002h 1762 | dw 08203h 1763 | dw 05404h 1764 | dw 08005h 1765 | dw 00d06h 1766 | dw 03e07h 1767 | dw 00008h 1768 | dw 04009h 1769 | dw 0000fh 1770 | dw 0ea10h 1771 | dw 0ae11h 1772 | dw 0df12h 1773 | dw 02813h 1774 | dw 00014h 1775 | dw 0e715h 1776 | dw 00616h 1777 | dw 0e317h 1778 | dw 00101h 1779 | dw 00604h 1780 | dw 04005h 1781 | dw 00506h 1782 | dw 04110h 1783 | dw 00013h 1784 | x320y400 dw 00063h 1785 | dw 05f00h 1786 | dw 04f01h 1787 | dw 05002h 1788 | dw 08203h 1789 | dw 05404h 1790 | dw 08005h 1791 | dw 0bf06h 1792 | dw 01f07h 1793 | dw 00008h 1794 | dw 04009h 1795 | dw 0000fh 1796 | dw 09c10h 1797 | dw 08e11h 1798 | dw 08f12h 1799 | dw 02813h 1800 | dw 00014h 1801 | dw 09615h 1802 | dw 0b916h 1803 | dw 0e317h 1804 | dw 00101h 1805 | dw 00604h 1806 | dw 04005h 1807 | dw 00506h 1808 | dw 04110h 1809 | dw 00013h 1810 | x400y600 dw 000e7h 1811 | dw 07000h 1812 | dw 06301h 1813 | dw 06402h 1814 | dw 09203h 1815 | dw 06504h 1816 | dw 08205h 1817 | dw 07006h 1818 | dw 0f007h 1819 | dw 00008h 1820 | dw 06009h 1821 | dw 0000fh 1822 | dw 05b10h 1823 | dw 08c11h 1824 | dw 05712h 1825 | dw 03213h 1826 | dw 00014h 1827 | dw 05815h 1828 | dw 07016h 1829 | dw 0e317h 1830 | dw 00101h 1831 | dw 00604h 1832 | dw 04005h 1833 | dw 00506h 1834 | dw 04110h 1835 | dw 00013h 1836 | x376y564 dw 000e7h 1837 | dw 06e00h 1838 | dw 05d01h 1839 | dw 05e02h 1840 | dw 09103h 1841 | dw 06204h 1842 | dw 08f05h 1843 | dw 06206h 1844 | dw 0f007h 1845 | dw 00008h 1846 | dw 06009h 1847 | dw 0000fh 1848 | dw 03710h 1849 | dw 08911h 1850 | dw 03312h 1851 | dw 02f13h 1852 | dw 00014h 1853 | dw 03c15h 1854 | dw 05c16h 1855 | dw 0e317h 1856 | dw 00101h 1857 | dw 00604h 1858 | dw 04005h 1859 | dw 00506h 1860 | dw 04110h 1861 | dw 00013h 1862 | x400y564 dw 000e3h 1863 | dw 07400h 1864 | dw 06301h 1865 | dw 06402h 1866 | dw 09703h 1867 | dw 06804h 1868 | dw 09505h 1869 | dw 06206h 1870 | dw 0f007h 1871 | dw 00008h 1872 | dw 06009h 1873 | dw 0310fh 1874 | dw 03710h 1875 | dw 08911h 1876 | dw 03312h 1877 | dw 03213h 1878 | dw 00014h 1879 | dw 03c15h 1880 | dw 05c16h 1881 | dw 0e317h 1882 | dw 00101h 1883 | dw 00604h 1884 | dw 04005h 1885 | dw 00506h 1886 | dw 04110h 1887 | dw 00013h 1888 | x360y350 dw 00067h 1889 | dw 06b00h 1890 | dw 05901h 1891 | dw 05a02h 1892 | dw 08e03h 1893 | dw 05e04h 1894 | dw 08a05h 1895 | dw 0bf06h 1896 | dw 01f07h 1897 | dw 00008h 1898 | dw 04009h 1899 | dw 0000fh 1900 | dw 08810h 1901 | dw 08511h 1902 | dw 05d12h 1903 | dw 02d13h 1904 | dw 00014h 1905 | dw 06d15h 1906 | dw 0ba16h 1907 | dw 0e317h 1908 | dw 00101h 1909 | dw 00604h 1910 | dw 04005h 1911 | dw 00506h 1912 | dw 04110h 1913 | dw 00013h 1914 | 1915 | IF BGIVERSION GE 3 1916 | _DATA ENDS 1917 | ENDIF 1918 | 1919 | end 1920 |  1921 | --------------------------------------------------------------------------------