'=========================================================================== ' Subject: SVGA 16 BIT MODE Date: 11-08-98 (18:49) ' Author: ATyler85@aol.com Code: QB, PDS ' Origin: ATyler85@aol.com Packet: GRAPHICS.ABC '=========================================================================== ' This program is a SVGA 16 bit mode. It requires a VESA SVGA card. If you ' make any improvements on this program or have any questions send them to ' ATyler85@aol.com DECLARE SUB InitBank () DECLARE SUB DEMO (num%) DECLARE SUB DrawTextV (Text$, Row!, Column!, clr&, bclr&) DECLARE SUB LoadText () DECLARE FUNCTION DetectVESA% () DECLARE FUNCTION SetMode% (mode%) DECLARE SUB SetText () DECLARE SUB Pixel (X%, Y%, r%, g%, b%) DEFINT A-Z '$INCLUDE: 'qb.bi' DIM SHARED RegsX AS RegTypeX, Regs AS RegType, BANK.asm$, pal(256, 3) COMMON SHARED xRes, yRes, yOffset, curBank, winGranul, Segment, bpp CLS TYPE VGAInfoBlock VESASignature AS STRING * 4 VESAVersion AS INTEGER OEMStringPointer AS LONG Capabilities AS LONG VideoModePtr AS INTEGER TotalMemory AS INTEGER Reserved AS STRING * 236 END TYPE TYPE ModeInfoBlock ModeAttributes AS INTEGER WinAAttributes AS STRING * 1 WinBAttributes AS STRING * 1 WinGranularity AS INTEGER WinSize AS INTEGER WinASegment AS INTEGER WinBSegment AS INTEGER WinFuncPointer AS LONG BytesPerScanLine AS INTEGER XResolution AS INTEGER YResolution AS INTEGER XCharSize AS STRING * 1 YCharSize AS STRING * 1 NumberOfPlanes AS STRING * 1 BitsPerPixel AS STRING * 1 NumberOfBanks AS STRING * 1 MemoryModel AS STRING * 1 BankSize AS STRING * 1 NumberOfImagePages AS STRING * 1 SizeOfBank AS STRING * 1 RedMaskSize AS STRING * 1 RedFieldPosition AS STRING * 1 GreenMaskSize AS STRING * 1 GreenFieldPosition AS STRING * 1 BlueMaskSize AS STRING * 1 BlueFieldPosition AS STRING * 1 RsvdMaskSize AS STRING * 1 RsvdFieldPosition AS STRING * 1 DirectColorModeInfo AS STRING * 1 Reserved AS STRING * 216 END TYPE InitBank IF DetectVESA = 0 THEN PRINT "No VESA driver is installed.": END pages = SetMode(&H111) DEMO pleasetypeakey$ = INPUT$(1) SetText SUB DEMO FOR Y = 0 TO yRes - 1 'Fill the screen with pixels FOR X = 0 TO xRes - 1 Pixel X, Y, X \ 40 + Y \ 30, ABS(X - (xRes \ 2)) \ 10 + ABS(Y - (yRes - 1)) \ 15, ABS(X - (xRes - 1)) \ 40 + Y \ 30 NEXT X NEXT Y END IF END SUB FUNCTION DetectVESA DIM VGAInfo AS VGAInfoBlock RegsX.ax = &H4F00 RegsX.es = VARSEG(VGAInfo) RegsX.di = VARPTR(VGAInfo) CALL INTERRUPTX(&H10, RegsX, RegsX) IF RegsX.ax = &H4F THEN DetectVESA = 1 IF VGAInfo.VESASignature <> "VESA" THEN DetectVESA = 0 PRINT "VESA Version:"; RTRIM$(STR$(VGAInfo.VESAVersion \ 255)); "."; PRINT LTRIM$(STR$(VGAInfo.VESAVersion AND 255)) END IF END FUNCTION SUB InitBank BANK.asm$ = "" BANK.asm$ = BANK.asm$ + CHR$(&H55) 'PUSH BP BANK.asm$ = BANK.asm$ + CHR$(&H89) + CHR$(&HE5) 'MOV BP,SP BANK.asm$ = BANK.asm$ + CHR$(&HB8) + CHR$(&H5) + CHR$(&H4F) 'MOV AX,4F05 BANK.asm$ = BANK.asm$ + CHR$(&HBB) + CHR$(&H0) + CHR$(&H0) 'MOV BX,0000 BANK.asm$ = BANK.asm$ + CHR$(&H8B) + CHR$(&H56) + CHR$(&H6) 'MOV DX,[BP+06] BANK.asm$ = BANK.asm$ + CHR$(&HCD) + CHR$(&H10) 'INT 10 BANK.asm$ = BANK.asm$ + CHR$(&H5D) 'POP BP BANK.asm$ = BANK.asm$ + CHR$(&HCB) 'RETF END SUB SUB Pixel (X, Y, r, g, b) r = r AND 31: g = g AND 63: b = b AND 31 yA& = (Y + yOffset) * 2 offset& = yA& * xRes + (X * 2) BANK = offset& \ &H10000 offset& = offset& - &H10000 * BANK IF BANK <> curBank THEN curBank = BANK BANK% = curBank ' Regs.ax = &H4F05 ' Regs.bx = 0 ' Regs.dx = curBank ' CALL INTERRUPT(&H10, Regs, Regs) DEF SEG = VARSEG(BANK.asm$) CALL ABSOLUTE(BYVAL BANK%, SADD(BANK.asm$)) DEF SEG DEF SEG = Segment END IF hiClr = r * 8 + g \ 8: loClr = (g AND 7) * 32 + b POKE offset&, loClr: POKE offset& + 1, hiClr END SUB FUNCTION SetMode (mode) DIM ModeInfo AS ModeInfoBlock RegsX.ax = &H4F01 RegsX.cx = mode RegsX.es = VARSEG(ModeInfo) RegsX.di = VARPTR(ModeInfo) CALL INTERRUPTX(&H10, RegsX, RegsX) IF ModeInfo.ModeAttributes AND 1 = 0 THEN PRINT "Cannot access mode" winGranul = 64 \ ModeInfo.WinGranularity xRes = ModeInfo.XResolution yRes = ModeInfo.YResolution IF ModeInfo.WinSize < 64 THEN PRINT "This program only works with those modes with more than 64k of window" SetMode = 0 EXIT FUNCTION 'these routines. END IF IF ASC(ModeInfo.MemoryModel) <> 6 THEN PRINT "This Screen Mode is not available" SetMode = 0 EXIT FUNCTION END IF Segment = ModeInfo.WinASegment DEF SEG = Segment Regs.ax = &H4F02 'Set the mode. Regs.bx = mode CALL INTERRUPT(&H10, Regs, Regs) IF Regs.ax <> &H4F THEN 'Make sure it worked. PRINT "Screen mode could not be initialized" SetMode = 0 EXIT FUNCTION END IF curBank = 0 'Initialize bank and page. yOffset = 0 bpp = ASC(ModeInfo.BitsPerPixel) SetMode = ASC(ModeInfo.NumberOfImagePages) + 1 END FUNCTION SUB SetText Regs.ax = &H3 CALL INTERRUPT(&H10, Regs, Regs) END SUB