'=========================================================================== ' Subject: SVGA TARGA IMAGE VIEWER Date: 05-15-98 (02:52) ' Author: Andrew S. Gibson Code: QB, PDS ' Origin: zapf_dingbat@juno.com Packet: GRAPHICS.ABC '=========================================================================== ' This is a SuperVga Targa image viewer, I am able to use this on my 386sx ' that has a Trident 8900 (512k) with a VESA BIOS Version 1.2 tsr resident. ' It worked charmingly... Alas now I have a Phoenix S3 Vision 864 with two ' megabytes of display ram and these QuickBASIC SuperVGA Routines says it ' can't find any display modes (BS, I have used 8 other programs and these ' find everything !). As we all know Vision 864s have VESA BIOS 1.2 support ' built in. If anybody knows where I can send email to Glenn Stumpff, Author ' of QBSVGA 3.2 - I'd really appreciate this. I'd like to get an upgrade, or ' find something much better.. anyway this program has internal help - it's ' meant to be used as a command line utility. You need QuickBASIC 4.5 ! ' If you can make sense of all these things feel free to translate this to ' another form of the basic language. Hey as least the VESA detection ' actually works... only a couple of routines from QBSVGA 3.2 are used, and ' I got the VESA bank switching code from somebody else's submission and ' incorporated it in this and other programs.. My mail address is ' Zapf_DingBat@JUNO.COM - a text only mail service. DEFINT A-Z DECLARE FUNCTION BIN$ (NUM AS LONG) DECLARE FUNCTION DPOINT% (XCOORD, YCOORD) DECLARE FUNCTION SelectTGAImageMode% (TGAFILE$) DECLARE SUB BSCREEN (MODE, CL, APAGE, VPAGE) DECLARE SUB DCLS (HorizMax, VertMax) DECLARE SUB DPSET (XCOORD, YCOORD, CL%) DECLARE SUB FINDVESA (MODE, HR, VR, NC) DECLARE SUB HELP () DECLARE SUB PAL (Act$) DECLARE SUB ParseCmdLine (cmd$, Params$(), Found%) DECLARE SUB PressAnyKey () DECLARE SUB STDOUT (MESSAGETEXT$) DECLARE SUB SwitchBank (NB%) DECLARE SUB TGALoad (File$) DECLARE SUB WriteSuperVgaRaw (SRWName$) DECLARE SUB XBeep (High, Low, Duration) 'REGTYPE.BAS - Include file for CALL INTERRUPT TYPE RegType AX AS INTEGER BX AS INTEGER CX AS INTEGER DX AS INTEGER BP AS INTEGER SI AS INTEGER DI AS INTEGER flags AS INTEGER DS AS INTEGER ES AS INTEGER END TYPE TYPE TGA Info AS STRING * 1 Clr AS STRING * 1 Img AS STRING * 1 Orig AS INTEGER Col AS INTEGER Bits AS STRING * 1 XVal AS INTEGER YVal AS INTEGER W AS INTEGER H AS INTEGER Pix AS STRING * 1 Desc AS STRING * 1 END TYPE CONST TRUE = -1, FALSE = 0 DIM SHARED Registers AS RegType, DisplayPictureWhileLoading, ApplyEightBPPGScale DIM SHARED r(255), g(255), b(255), SixteenMillionColors, ForceGrayScale, ConvertToSRaw DIM SHARED Bank%, Table&(0 TO 1600), HDR AS TGA, Ingraphics, BPP, VesMode, SeeInfo DIM Params$(1 TO 10) COMMON SHARED /DEFAULTS/ ACPAGE, DEFLTC, VESSUP, HMAX, VMAX, BVCBL, BITPLANES, BITSPIXEL COMMON SHARED /VIEWPORT/ VXL, VYL, VXR, VYR, VCOL, VBORD '$DYNAMIC CLEAR , 2048 ' Mode list ' MODE = 26: 640 x 400 x 256 ' MODE = 14: 640 x 480 x 256 ' MODE = 16: 800 x 600 x 256 ' MODE = 18: 1024 x 768 x 256 ' MODE = 20: 1200 x 1024 x 256 ' MODE = 22: 1600 x 1200 x 256 ' program defaults Hrequest = FALSE SixteenMillionColors = FALSE ForceGrayScale = FALSE DisplayPictureWhileLoading = FALSE ApplyEightBPPGScale = FALSE ConvertToSRaw = FALSE SeeInfo = FALSE ParseCmdLine COMMAND$, Params$(), NumParams% 'IF NumParams% = FALSE THEN Help: Noff = TRUE FOR II% = 1 TO NumParams% Q$ = Params$(II%) IF LEFT$(Q$, 6) = "-CSRW:" THEN 'This HAS TO BE LAST !!!!!!!!!! SRWN$ = UCASE$(RIGHT$(Q$, LEN(Q$) - 6)): ConvertToSRaw = TRUE EXIT FOR IF SRWN$ = "" THEN STDOUT "You need to specify a conversion filename." + CHR$(10) + CHR$(13): END END IF SELECT CASE Q$ CASE "?", "HELP", "-?", "-HELP": HELP: Hrequest = TRUE: EXIT FOR CASE IS = "-C:16M": SixteenMillionColors = TRUE CASE IS = "-GRAYDISPLAY", "-GD": ForceGrayScale = TRUE CASE IS = "-DISPLAYPICTUREWHILELOADING", "-DPWL": DisplayPictureWhileLoading = TRUE CASE IS = "-A8GS", "-ABP8GS": ApplyEightBPPGScale = TRUE CASE IS = "-PI", "-PICINFO": SeeInfo = TRUE CASE ELSE Filename$ = Q$ END SELECT NEXT II% IF Hrequest = TRUE THEN GOTO Term 'bail out ON ERROR GOTO HandleErrors IF Filename$ = "" THEN STDOUT "You must specify a file name on the command line." + CHR$(10) + CHR$(13) GOTO Term END IF VesMode = SelectTGAImageMode%(Filename$) SELECT CASE VesMode CASE -2: GOTO Term CASE -3: GOTO Term CASE -4 STDOUT "The Targa image you want to view is too large for any modes supported." + CHR$(10) + CHR$(13) STDOUT COMMAND$ + CHR$(10) + CHR$(13) STDOUT "has a Height of " + LTRIM$(STR$(HDR.H)) + " pixels and a width of " + LTRIM$(STR$(HDR.H)) + " pixels." + CHR$(10) + CHR$(13) STDOUT "This Targa Image viewer currently only supports these VESA Video Modes:" + CHR$(10) + CHR$(13) + CHR$(10) STDOUT "Width x Height x Maximum Colors" + CHR$(10) + CHR$(13) STDOUT " 640 x 400 x 256 Colors" + CHR$(10) + CHR$(13) STDOUT " 640 x 480 x 256 Colors" + CHR$(10) + CHR$(13) STDOUT " 800 x 600 x 256 Colors" + CHR$(10) + CHR$(13) STDOUT "1024 x 768 x 256 Colors" + CHR$(10) + CHR$(13) STDOUT "1200 x 1024 x 256 Colors" + CHR$(10) + CHR$(13) STDOUT "1600 x 1200 x 256 Colors" + CHR$(10) + CHR$(13) GOTO Term CASE IS = 26 FOR Height% = 0 TO 399: Table&(Height%) = Height% * 640&: NEXT Height% CASE IS = 14 FOR Height% = 0 TO 479: Table&(Height%) = Height% * 640&: NEXT Height% CASE IS = 16 FOR Height% = 0 TO 599: Table&(Height%) = Height% * 800&: NEXT Height% CASE IS = 18 FOR Height% = 0 TO 767: Table&(Height%) = Height% * 1024&: NEXT Height% CASE IS = 20 FOR Height% = 0 TO 1023: Table&(Height%) = Height% * 1200&: NEXT Height% CASE IS = 22 FOR Height% = 0 TO 1199: Table&(Height%) = Height% * 1600&: NEXT Height% END SELECT BSCREEN VesMode, 0, 0, 0 Ingraphics = TRUE TGALoad Filename$ IF ConvertToSRaw = TRUE THEN WriteSuperVgaRaw SRWN$ END IF XBeep 5, 8, 350 ZX$ = INPUT$(1) PAL "FADEOUT" BSCREEN 0, 0, 0, 0 Term: END '256 Gray Scale - if needed (0 to 64) GrayTFSC: DATA 0,0,0,0,0,0,0,0,0,0,0,0 DATA 1,1,1,1,1,1,1,1,1,1,1,1 DATA 2,2,2,2,2,2,2,2,2,2,2,2 DATA 3,3,3,3,3,3,3,3,3,3,3,3 DATA 4,4,4,4,4,4,4,4,4,4,4,4 DATA 5,5,5,5,5,5,5,5,5,5,5,5 DATA 6,6,6,6,6,6,6,6,6,6,6,6 DATA 7,7,7,7,7,7,7,7,7,7,7,7 DATA 8,8,8,8,8,8,8,8,8,8,8,8 DATA 9,9,9,9,9,9,9,9,9,9,9,9 DATA 10,10,10,10,10,10,10,10,10,10,10,10 DATA 11,11,11,11,11,11,11,11,11,11,11,11 DATA 12,12,12,12,12,12,12,12,12,12,12,12 DATA 13,13,13,13,13,13,13,13,13,13,13,13 DATA 14,14,14,14,14,14,14,14,14,14,14,14 DATA 15,15,15,15,15,15,15,15,15,15,15,15 DATA 16,16,16,16,16,16,16,16,16,16,16,16 DATA 17,17,17,17,17,17,17,17,17,17,17,17 DATA 18,18,18,18,18,18,18,18,18,18,18,18 DATA 19,19,19,19,19,19,19,19,19,19,19,19 DATA 20,20,20,20,20,20,20,20,20,20,20,20 DATA 21,21,21,21,21,21,21,21,21,21,21,21 DATA 22,22,22,22,22,22,22,22,22,22,22,22 DATA 23,23,23,23,23,23,23,23,23,23,23,23 DATA 24,24,24,24,24,24,24,24,24,24,24,24 DATA 25,25,25,25,25,25,25,25,25,25,25,25 DATA 26,26,26,26,26,26,26,26,26,26,26,26 DATA 27,27,27,27,27,27,27,27,27,27,27,27 DATA 28,28,28,28,28,28,28,28,28,28,28,28 DATA 29,29,29,29,29,29,29,29,29,29,29,29 DATA 30,30,30,30,30,30,30,30,30,30,30,30 DATA 31,31,31,31,31,31,31,31,31,31,31,31 DATA 32,32,32,32,32,32,32,32,32,32,32,32 DATA 33,33,33,33,33,33,33,33,33,33,33,33 DATA 34,34,34,34,34,34,34,34,34,34,34,34 DATA 35,35,35,35,35,35,35,35,35,35,35,35 DATA 36,36,36,36,36,36,36,36,36,36,36,36 DATA 37,37,37,37,37,37,37,37,37,37,37,37 DATA 38,38,38,38,38,38,38,38,38,38,38,38 DATA 39,39,39,39,39,39,39,39,39,39,39,39 DATA 40,40,40,40,40,40,40,40,40,40,40,40 DATA 41,41,41,41,41,41,41,41,41,41,41,41 DATA 42,42,42,42,42,42,42,42,42,42,42,42 DATA 43,43,43,43,43,43,43,43,43,43,43,43 DATA 44,44,44,44,44,44,44,44,44,44,44,44 DATA 45,45,45,45,45,45,45,45,45,45,45,45 DATA 46,46,46,46,46,46,46,46,46,46,46,46 DATA 47,47,47,47,47,47,47,47,47,47,47,47 DATA 48,48,48,48,48,48,48,48,48,48,48,48 DATA 49,49,49,49,49,49,49,49,49,49,49,49 DATA 50,50,50,50,50,50,50,50,50,50,50,50 DATA 51,51,51,51,51,51,51,51,51,51,51,51 DATA 52,52,52,52,52,52,52,52,52,52,52,52 DATA 53,53,53,53,53,53,53,53,53,53,53,53 DATA 54,54,54,54,54,54,54,54,54,54,54,54 DATA 55,55,55,55,55,55,55,55,55,55,55,55 DATA 56,56,56,56,56,56,56,56,56,56,56,56 DATA 57,57,57,57,57,57,57,57,57,57,57,57 DATA 58,58,58,58,58,58,58,58,58,58,58,58 DATA 59,59,59,59,59,59,59,59,59,59,59,59 DATA 60,60,60,60,60,60,60,60,60,60,60,60 DATA 61,61,61,61,61,61,61,61,61,61,61,61 DATA 62,62,62,62,62,62,62,62,62,62,62,62 DATA 63,63,63,63,63,63,63,63,63,63,63,63 HandleErrors: IF Ingraphics = TRUE THEN PAL "FADEIN" PAL "RESTORE" END IF BSCREEN 0, 0, 0, 0 CLOSE STDOUT "The following error has occurred:" + CHR$(10) + CHR$(13) SELECT CASE ERR CASE IS = 5: STDOUT "Illegal Function Call." + CHR$(10) + CHR$(13) CASE IS = 6: STDOUT "Math Overflow." + CHR$(10) + CHR$(13) CASE IS = 7: STDOUT "Program Error: Out of memory." + CHR$(10) + CHR$(13) STDOUT "I used up all of the DGROUP space, Try again." + CHR$(10) + CHR$(13) CASE IS = 9: STDOUT "Program Error: Array Subscript out of range." + CHR$(10) + CHR$(13) STDOUT "Upper limit of allocated space exceeded." + CHR$(10) + CHR$(13) CASE IS = 14: STDOUT "Program Error: Out of String Space" + CHR$(10) + CHR$(13) CASE IS = 24: STDOUT "Informative Error: Device timeout" + CHR$(10) + CHR$(13) STDOUT "Turn on your printer or activate `on-line' mode." + CHR$(10) + CHR$(13) CASE IS = 25: STDOUT "Printer Error: Device fault" + CHR$(10) + CHR$(13) STDOUT "I can't talk to your printer or print que." + CHR$(10) + CHR$(13) CASE IS = 27: STDOUT "Printer Error: Out of paper" + CHR$(10) + CHR$(13) STDOUT "Put Paper in your printer." + CHR$(10) + CHR$(13) CASE IS = 52: STDOUT "Program or User Error: Bad File Name or number" + CHR$(10) + CHR$(13) STDOUT "You provided a bad file name or I tried to use a file number that's closed." + CHR$(10) + CHR$(13) CASE IS = 53: STDOUT "FileManager/User input Error: File not found" STDOUT "I cannot find the file you requested." + CHR$(10) + CHR$(13) CASE IS = 54: STDOUT "FileManager/Programmer Error: Bad file mode" + CHR$(10) + CHR$(13) STDOUT "I am unable to read a file properly. Make sure the input file is NOT a" + CHR$(10) + CHR$(13) STDOUT "text file !" + CHR$(10) + CHR$(13) CASE IS = 55: STDOUT "FileManager Error: File already open" + CHR$(10) + CHR$(13) STDOUT "A file was already opened, all files are now closed." + CHR$(10) + CHR$(13) CASE IS = 57: STDOUT "System Fault: Device I/O error" + CHR$(10) + CHR$(13) STDOUT "I can not 'talk' to a specific device." + CHR$(10) + CHR$(13) CASE IS = 58: STDOUT "Informative Error: File already exists" + CHR$(10) + CHR$(13) CASE IS = 59: STDOUT "FileManager Error: Bad record length" + CHR$(10) + CHR$(13) STDOUT "A database record of some sort is not long enough or is too long." + CHR$(10) + CHR$(13) CASE IS = 61: STDOUT "Informative Error: Disk FULL" + CHR$(10) + CHR$(13) STDOUT "Free up some disk space." + CHR$(10) + CHR$(13) CASE IS = 62: STDOUT "FileManager Error: Input past end of file." + CHR$(10) + CHR$(13) STDOUT "Attempt to read beyond the end of current file." + CHR$(10) + CHR$(13) CASE IS = 63: STDOUT "Program Error: Bad record number" + CHR$(10) + CHR$(13) STDOUT "A database record of some sort doesn't exist." + CHR$(10) + CHR$(13) CASE IS = 64: STDOUT "User Error: Bad file name" + CHR$(10) + CHR$(13) STDOUT "You specifically told me to use a file name that is incorrect." + CHR$(10) + CHR$(13) CASE IS = 67: STDOUT "FileManager Fault: Too many files open" + CHR$(10) + CHR$(13) STDOUT "I can't open more files than listed in your CONFIG.SYS file." + CHR$(10) + CHR$(13) CASE IS = 68: STDOUT "System Error: Device UNAVAILABLE" + CHR$(10) + CHR$(13) STDOUT "A user serviceable device is not accessable to the computer." + CHR$(10) + CHR$(13) CASE IS = 71: STDOUT "User or System Error: Disk not Ready" + CHR$(10) + CHR$(13) STDOUT "Insert a diskette in the current drive. (Excepting Hardrives)" + CHR$(10) + CHR$(13) CASE IS = 72: STDOUT "Serious Informative Error: Disk-Media error" + CHR$(10) + CHR$(13) STDOUT "The recordable media surface of the current disk has developed a defect." + CHR$(10) + CHR$(13) CASE IS = 73: STDOUT "Informative Error: Feature unavailable" + CHR$(10) + CHR$(13) STDOUT "An advanced capability is not available within this computer." + CHR$(10) + CHR$(13) CASE IS = 75: STDOUT "FileManager/User input Error: Path/File access error" + CHR$(10) + CHR$(13) CASE IS = 76: STDOUT "FileManager/User input Error: Path not found" + CHR$(10) + CHR$(13) STDOUT "The path to a file is non-existant." + CHR$(10) + CHR$(13) CASE IS = 77: STDOUT "FileManager/User input Error: File doesn't exist." + CHR$(10) + CHR$(13) CASE ELSE STDOUT "Error is unprintable. The Errorlevel is" + STR$(ERR) + "." + CHR$(10) + CHR$(13) END SELECT END REM $STATIC FUNCTION BIN$ (NUM AS LONG) ' ' This is a "functionized" version of code extracted from a more general ' numeric base conversion program by Robert B. Relf, (C) 1984. This just ' uses the part of Mr. Relf's code that converts decimal to binary. ' DIM x AS INTEGER NUM = (NUM + 65536) MOD 65536 BIN1$ = "" FOR x = 15 TO 0 STEP -1 IF NUM >= (2 ^ x) THEN BIN1$ = BIN1$ + "1" NUM = NUM - (2 ^ x) ELSE BIN1$ = BIN1$ + "0" END IF NEXT x BIN1$ = LEFT$(BIN1$, 8) + RIGHT$(BIN1$, 8) BIN$ = BIN1$ END FUNCTION SUB BSCREEN (MODE, CL, APAGE, VPAGE) ' ' Subroutine BSCREEN emulates the function of QB's SCREEN statement. ' It uses subroutine FINDVESA to find a video mode supported by a VESA ' bios that corresponds to a "QB-type" mode specified by MODE. The ' resolutions for each supported MODE integer are given below. ' ' MODE = 26: 640 x 400 x 256 ' MODE = 14: 640 x 480 x 256 ' MODE = 15: 800 x 600 x 16 ' MODE = 16: 800 x 600 x 256 ' MODE = 17: 1024 x 768 x 16 ' MODE = 18: 1024 x 768 x 256 ' MODE = 19: 1200 x 1024 x 16 ' MODE = 20: 1200 x 1024 x 256 ' MODE = 21: 1600 x 1200 x 16 ' MODE = 22: 1600 x 1200 x 256 ' MODE = 23: 132 x 25 x 16 (text) ' MODE = 24: 132 x 43 x 16 (text) ' MODE = 25: 132 x 50 x 16 (text) ' ' These routines should not be used with modes not specified here. Mode ' 0 is an allowable input; it corresponds to QB's SCREEN 0 and gets ' translated here to bios mode 3. (Except for more colors, I'm not aware ' of any higher modes, anyway, and why would you want to use these ' routines with the lower modes? QB's SCREEN statement will do that.) If ' a mode with the desired resolution and colors cannot be found, a mode ' will still be selected if one can be found with the desired resolution ' and *more* colors than necessary. ' ' The first four inputs are just as would be used with QB's SCREEN ' statement except that CL is the default color to print with, not some ' switch that determines whether color is displayed at all. Unlike the ' SCREEN statement, all parameters much be specified in the CALL. If the ' input video mode is the one that is already in effect, BSCREEN can be ' used to simply change default colors or displayed/active pages. (You ' might want to use subroutine BCOLOR for the former purpose.) BSCREEN ' should be called before any of the other routines are called. ' DIM CMODE AS INTEGER ' ' Store active page and default color in global variables. (Alias VPAGE ' with VP and make sure its value is valid.) ' ACPAGE = APAGE: IF ACPAGE < 0 THEN ACPAGE = 0 DEFLTC = CL: IF DEFLTC <= 0 THEN DEFLTC = 7 VP = VPAGE: IF VP < 0 THEN VP = 0 ' ' Get current video mode. If it is same as one being set, no mode change ' is made. The routine is just being used to change default colors ' (subroutine BCOLOR is simpler to use for that purpose) or pages. (The ' value of CMODE may get changed after VESA-awareness is determined.) ' Registers.AX = &HF00 CALL InterruptX(&H10, Registers, Registers) CMODE = Registers.AX AND &HFF ' ' Set visible page. ' Registers.AX = CINT(VP) + 1280 CALL InterruptX(&H10, Registers, Registers) ' ' Make correlation between "QB-type" modes and resolution of bios mode to ' be searched for. (Set default mode data in case invalid mode was input.) ' HR = 800: VR = 600: NC = 16 IF MODE = 14 THEN HR = 640: VR = 480 IF MODE = 15 OR MODE = 16 THEN HR = 800: VR = 600 IF MODE = 17 OR MODE = 18 THEN HR = 1024: VR = 768 IF MODE = 19 OR MODE = 20 THEN HR = 1280: VR = 1024 IF MODE = 21 OR MODE = 22 THEN HR = 1600: VR = 1200 IF MODE = 23 THEN VR = 25 IF MODE = 24 THEN VR = 43 IF MODE = 25 THEN VR = 50 IF MODE = 26 THEN HR = 640: VR = 400 IF MODE = 0 OR MODE = 15 OR MODE = 17 OR MODE = 19 OR MODE = 21 OR MODE > 22 THEN NC = 16 IF MODE = 14 OR MODE = 16 OR MODE = 18 OR MODE = 20 OR MODE = 22 OR MODE = 26 THEN NC = 256 IF MODE = 23 OR MODE = 24 OR MODE = 25 THEN HR = 132 ' ' Define global resolution limits (zero-based) and viewport defaults. ' HMAX = HR - 1: VMAX = VR - 1: VXL = 0: VYL = 0: VXR = HMAX: VYR = VMAX ' ' Set VCOL to a negative number so other routines can tell that BVIEW ' wasn't called yet. ' VCOL = -1 IF MODE <> 0 THEN ' ' SCREEN is not being reset to text mode. Find VESA mode with desired ' resolution. If FINDVESA can't find a requisite VESA mode, whether ' because system isn't VESA-aware or other reasons, BMODE is returned as ' -1. (If system is detected as VESA aware, an "error code" of 0 is ' defined via VESSUP variable. If VESA cannot be detected, VESSUP is set ' to unity.) Before using FINDVESA, however, look for overriding bios ' mode definition via DOS environment variable. (This environment ' is SET with the syntax "MODE##=bios-mode", where ## is the two-digit ' QB-type mode integer that corresponds to bios-mode.) ' QBMODE$ = "MODE" + LTRIM$(RTRIM$(STR$(MODE))) EMODE$ = MID$(LTRIM$(ENVIRON$(QBMODE$)), 1, 80) BMODE = VAL("&H0" + EMODE$) ' ' In case FINDVESA isn't going to be used to find a VESA video mode or ' it *is* going to be used and in case it fails, set default bit planes ' per pixel and bits per pixel parameters. ' BITPLANES = 1: BITSPIXEL = 8 IF BMODE = 0 THEN ' ' "MODE##" environment variable didn't exist for input QB-type mode. ' FINDVESA BMODE, HR, VR, NC ' ' Except for text mode 3, there are no bios modes less than 4 that are ' of concern here. (There aren't likely any below 13h of any importance. ' I'm just taking into account "wierd" video adapters, such as mine, which ' will do a hex mode B.) ' IF BMODE >= 4 THEN ' ' VESA mode was found, hence, system is VESA-aware. Redetermine current ' video mode. ' Registers.AX = &H4F03 CALL InterruptX(&H10, Registers, Registers) CMODE = Registers.BX IF CMODE <> BMODE THEN ' ' VESA mode was found and it is different from current mode; change video ' mode. ' Registers.AX = &H4F02 Registers.BX = BMODE CALL InterruptX(&H10, Registers, Registers) IF MODE < 23 THEN ' ' Initialize mouse if driver is installed via interrupt 33h. ' 'IF QRYMOUSE = -1 THEN CALL MOUSINIT END IF END IF ELSE ' ' VESA mode couldn't be found. Assume "OEM SVGA" and ask user for ' hexadecimal mode integer that corresponds to desired video mode. Set ' VESSUP according to value of input bios mode. (Put screen in standard ' QB text mode so prompt can be seen in case it was already in some ' QB-unreadable graphics screen.) ' Registers.AX = 3 CALL InterruptX(&H10, Registers, Registers) RES$ = LTRIM$(RTRIM$(STR$(HR))) + " x " + LTRIM$(RTRIM$(STR$(VR))) + " x " RES$ = RES$ + LTRIM$(RTRIM$(STR$(NC))) STDOUT "VESA video card may not support this resolution:" + RES$ + CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13) STDOUT "Type this from DOS and try again:" + CHR$(10) + CHR$(13) STDOUT "SET MODE" + LTRIM$(RTRIM$(STR$(MODE))) + "=(Vesa BIOS mode number in hexadecimal)" + CHR$(10) + CHR$(13) END ' ' Video mode is changed regardless of its present state when mode had to ' be prompted for. (Even if the above text-mode change hadn't occurred, ' the prompt for the mode needs to be cleared.) ' VESSUP = 1 Registers.AX = VAL("&H" + M$) ' ' Use VESA call to set video mode if it is 100h or above. Otherwise, ' use standard bios call. ' IF Registers.AX > 255 THEN VESSUP = 0 Registers.BX = Registers.AX Registers.AX = &H4F02 END IF CALL InterruptX(&H10, Registers, Registers) IF MODE < 23 THEN ' ' Initialize mouse if driver is installed via interrupt 33h. ' 'IF QRYMOUSE = -1 THEN CALL MOUSINIT END IF END IF ELSE ' ' "MODE##" environment variable exists for desired mode. Set VESSUP ' according to value of bios mode. ' VESSUP = 1: IF BMODE > 255 THEN VESSUP = 0 ' ' Re-acquire and test current video mode before changing it. ' IF VESSUP = 1 THEN Registers.AX = &HF00 CALL InterruptX(&H10, Registers, Registers) CMODE = Registers.AX AND &HFF Registers.AX = BMODE ELSE Registers.AX = &H4F03 CALL InterruptX(&H10, Registers, Registers) CMODE = Registers.BX Registers.AX = &H4F02 Registers.BX = BMODE END IF IF CMODE <> BMODE THEN CALL InterruptX(&H10, Registers, Registers) IF MODE < 23 THEN ' ' Initialize mouse if driver is installed via interrupt 33h. ' 'IF QRYMOUSE = -1 THEN CALL MOUSINIT END IF END IF END IF ' ' Global variable BVCBL is normally 0. BVIEW sets it to 1 just before ' calling BLINE to draw a border around the viewport. (BLINE uses this ' variable to know not to enforce viewport constraints when BVIEW tries to ' draw a box just outside of the viewport. (BVIEW resets it to unity when ' it's finished.) Define fictitious values for global mouse position ' variables. ' BVCBL = 0 ELSE ' ' SCREEN 0 is being emulated. Use what should be a standard text mode ' for any SVGA system. (This mode is also set regardless of whether or ' not the video state is already there.) ' Registers.AX = 3 CALL InterruptX(&H10, Registers, Registers) ' ' Just to be safe, make sure QB knows what screen mode it's in. (The ' above call to interrupt 10 could probably be skipped, but QB's SCREEN 0 ' by itself doesn't necessarily leave you in the text mode you want when ' the screen isn't initially in a mode that QB recognizes.) ' END IF END SUB SUB DCLS (HorizMax, VertMax) FOR VMx = 0 TO VertMax FOR HMx = 0 TO HorizMax DPSET HMx, VMx, 0 NEXT HMx NEXT VMx END SUB FUNCTION DPOINT% (XCOORD, YCOORD) NewBank% = (Table&(YCOORD) + XCOORD) \ 65536 IF NewBank% <> Bank% THEN SwitchBank NewBank% DEF SEG = &HA000 DPOINT% = PEEK((Table&(YCOORD) + XCOORD) MOD 65536) DEF SEG END FUNCTION SUB DPSET (XCOORD, YCOORD, CL%) NewBank% = (Table&(YCOORD) + XCOORD) \ 65536 IF NewBank% <> Bank% THEN SwitchBank NewBank% DEF SEG = &HA000 POKE (Table&(YCOORD) + XCOORD) MOD 65536, CL% DEF SEG END SUB SUB FINDVESA (MODE, HR, VR, NC) ' ' This subroutine returns the VESA bios MODE integer (decimal) that has ' resolution HR x VR x NC, as input via the parameter list. If no such ' mode can be found, MODE is returned as -1. (If it finds a mode with ' the desired horizontal HR and vertical VR resolution but with more than ' NC colors, the mode is considered valid and is returned in MODE. (It ' will first try to find a mode with NC colors.)) ' ' To qualify as a valid, the mode must be supported by both hardware and ' bios. (FINDVESA is usually called by BSCREEN. There is not much reason ' to call it directly.) ' DIM VESA(1 TO 64) AS LONG, Byte AS LONG, MD(1 TO 257) AS INTEGER, COLORS(1 TO 256) DIM PLANES(1 TO 256) SM = VARSEG(VESA(1)): OS = VARPTR(VESA(1)) ' ' Set VESSUP to unity in case VESA bios cannot be detected. ' VESSUP = 1 ' ' Confirm VESA support and get pointer to list of supported VESA modes. ' Registers.AX = &H4F00 Registers.ES = CINT(SM) Registers.DI = CINT(OS) CALL InterruptX(&H10, Registers, Registers) DEF SEG = SM T$ = CHR$(PEEK(OS)) + CHR$(PEEK(OS + 1)) + CHR$(PEEK(OS + 2)) + CHR$(PEEK(OS + 3)) IF T$ <> "VESA" THEN GOTO NOSUP ' ' VESA = VESA bios version number. ' VESAFRC = PEEK(OS + 4) FIXFRC: VESAFRC = VESAFRC / 10 IF VESAFRC >= 1 THEN GOTO FIXFRC VESA = PEEK(OS + 5) + VESAFRC PSM = PEEK(OS + 16) + 256 * PEEK(OS + 17): POF = PEEK(OS + 14) + 256 * PEEK(OS + 15) ' ' Look for video mode that supports desired resolution. ' ' NMODES counts number of modes (possibly with different colors) with ' desired resolution. ' NMODES = 1 NEWMODE: DEF SEG = PSM MD(NMODES) = PEEK(POF) + 256 * PEEK(POF + 1): POF = POF + 2 'PRINT PEEK(POF) + 256 * PEEK(POF + 1): SLEEP IF MD(NMODES) = -1 THEN GOTO NOSUP Registers.AX = &H4F01 Registers.CX = MD(NMODES) Registers.ES = CINT(SM) Registers.DI = CINT(OS) CALL InterruptX(&H10, Registers, Registers) DEF SEG = SM ' ' First byte at segment SM stores "support information" about mode under ' analysis. ' Byte = CLNG(PEEK(OS) + 256 * PEEK(OS + 1)) b$ = LTRIM$(RTRIM$(BIN$(Byte))) ' ' Bits 0 and 2 indicate support (or lack of it) in hardware and BIOS. ' HARD$ = MID$(b$, 16, 1) BIOS$ = MID$(b$, 14, 1) IF HARD$ = "0" OR BIOS$ = "0" THEN GOTO NEWMODE ' ' Bit 4 indicates graphics or text mode. ' GMSW$ = MID$(b$, 12, 1) ' ' Bit 1 indicates the presence of extended information. If no extended ' information is available for this mode, it cannot be determined that ' it supports the required HR x VR resolution. ' EXTINF$ = MID$(b$, 15, 1) IF EXTINF$ = "0" THEN GOTO NEWMODE ' ' Character sizes are needed to correct stored resolution data for some ' VESA bioses. ' HS = PEEK(OS + 22): VS = PEEK(OS + 23) HRM = PEEK(OS + 18) + 256 * PEEK(OS + 19): VRM = PEEK(OS + 20) + 256 * PEEK(OS + 21) IF VESA < 1.2 THEN IF GMSW$ = "0" THEN HRM = HRM / HS: VRM = VRM / VS IF (MD(NMODES) >= 0 AND MD(NMODES) <= 6) OR MD(NMODES) = 13 THEN VRM = VRM / 2 IF MD(NMODES) = 14 OR MD(NMODES) = 19 THEN VRM = VRM / 2 END IF IF HR <> HRM OR VR <> VRM THEN GOTO NEWMODE COLORS(NMODES) = 2! ^ CSNG(PEEK(OS + 25)) ' ' Get number of bit planes. (Subroutines BGET AND BPUT need it. They ' also need the number of bits per pixel. This is actually what was just ' reported by the VESA bios, above. It will be reobtained from the COLORS ' parameter later.) ' PLANES(NMODES) = PEEK(OS + 24) ' ' Get all modes with required resolution, regardless of color. (Later ' on the one with NC colors, if it exists, will be chosen. (But the ' possibility that the one with the right number of colors will be found ' first is taken into account.)) ' IF COLORS(NMODES) = NC THEN GOTO RETMODE IF NMODES < 256 THEN NMODES = NMODES + 1: GOTO NEWMODE RETMODE: ' ' Since VESA was detected, store corresponding error code. ' VESSUP = 0 FOR I = 1 TO NMODES K = I IF COLORS(I) = NC THEN BITSPIXEL = INT(LOG(COLORS(I)) / LOG(2) + .001) IF COLORS(I) = NC THEN MODE = CSNG(MD(I)): BITPLANES = PLANES(I): GOTO QUIT NEXT I FOR I = 1 TO NMODES K = I IF COLORS(I) > NC THEN BITSPIXEL = INT(LOG(COLORS(I)) / LOG(2) + .001) IF COLORS(I) > NC THEN MODE = CSNG(MD(I)): BITPLANES = PLANES(I): GOTO QUIT NEXT I NOSUP: ' ' Requisite VESA mode couldn't be found. Return negative mode value as ' switch for calling routine to recognize that fact. ' MODE = -1 QUIT: DEF SEG END SUB SUB HELP STDOUT "Targa Image viewer Version .7200á" + CHR$(10) + CHR$(13) STDOUT "Command line arguments available are:" + CHR$(10) + CHR$(13) + CHR$(10) STDOUT "/? or /HELP - This help text. This switch takes precedent over any parameter." + CHR$(10) + CHR$(13) + CHR$(10) STDOUT "/C:16M - Allow use of Hicolor/Truecolor palette in the Targa image. (If" + CHR$(10) + CHR$(13) STDOUT " any such palette exists.) Video adapters that only support 256" + CHR$(10) + CHR$(13) STDOUT " thousand colors will not display a Hicolor/Truecolor Targa" + CHR$(10) + CHR$(13) STDOUT " image in the right colors!" + CHR$(10) + CHR$(13) + CHR$(10) STDOUT "/GD - Force displaying of picture in gray scale. (If the Bits Per" + CHR$(10) + CHR$(13) STDOUT " Pixel in the image header equals eight then a gray scale" + CHR$(10) + CHR$(13) STDOUT " palette based on 0 to 63 will be used, otherwise a full" + CHR$(10) + CHR$(13) STDOUT " two hundred fifty-six gray scale palette will be used (0 to 255)." + CHR$(10) + CHR$(13) STDOUT "/DPWL - Display picture while it loads, otherwise you see a black screen." + CHR$(10) + CHR$(13) STDOUT "/A8GS - Apply the 8 BPP gray scale palette to a 24 BPP Targa image." + CHR$(10) + CHR$(13) STDOUT " This only happens if the image has 24 bits per pixel." + CHR$(10) + CHR$(13) STDOUT " Recommended for 256k color video adapters. (Takes Priority over" + CHR$(10) + CHR$(13) STDOUT " 'GD' switch when applicable.)" + CHR$(10) + CHR$(13) + CHR$(10) STDOUT "/PI - Display picture info for 8 seconds." + CHR$(10) + CHR$(13) PressAnyKey STDOUT "/CSRW:Name - Converts TGA file to a RAW image format, Replace 'Name' with a" + CHR$(10) + CHR$(13) STDOUT " valid DOS filename, a pathname may be included. *THIS PARAMETER" + CHR$(10) + CHR$(13) STDOUT " MUST BE THE LAST IN THE COMMAND LINE SEQUENCE !!!!!*" + CHR$(10) + CHR$(13) + CHR$(10) STDOUT "Any valid DOS filename that is a Targa image, a pathname may be included." + CHR$(10) + CHR$(13) STDOUT "Images that are eight & twenty-four Bits Per Pixel are supported." + CHR$(10) + CHR$(13) STDOUT "Pictures that don't seen to have palettes in them are displayed in gray scale." + CHR$(10) + CHR$(13) STDOUT "A space must be present between a filename and *any* parameter !" + CHR$(10) + CHR$(13) STDOUT "You can press ESCape to abort loading a picture." + CHR$(10) + CHR$(13) + CHR$(10) STDOUT "This Targa image viewer was coded by Andrew Gibson, whom in no way is liable" + CHR$(10) + CHR$(13) STDOUT "for any problems that may occur or accidents that may happen to your computer." + CHR$(10) + CHR$(13) STDOUT "I have tested this program to the best of my ability and have not found it to" + CHR$(10) + CHR$(13) STDOUT "be an unstable program. Although this image viewing program supports many" + CHR$(10) + CHR$(13) STDOUT "modes of operation not all of them will be available to you." + CHR$(10) + CHR$(13) END SUB SUB PAL (Act$) SELECT CASE UCASE$(Act$) ' "save","fadein","fadeout","restore","blackout" CASE "SAVE" FOR colour% = 0 TO 255 OUT &H3C7, colour% ' Set color to read r(colour%) = INP(&H3C9) ' read red value g(colour%) = INP(&H3C9) ' read green value b(colour%) = INP(&H3C9) ' read blue value NEXT CASE "FADEIN" DO done% = 0 FOR colour% = 0 TO 255 OUT &H3C7, colour% ' Set color to read red% = INP(&H3C9) ' read red value grn% = INP(&H3C9) ' read green value blu% = INP(&H3C9) ' read blue value ' Test the color values, decrementing if necessary. ' Set loop variable if saved palette not in use. IF red% < r(colour%) THEN red% = red% + 1: done% = 1 IF grn% < g(colour%) THEN grn% = grn% + 1: done% = 1 IF blu% < b(colour%) THEN blu% = blu% + 1: done% = 1 WAIT &H3DA, 8, 8 OUT &H3C8, colour% ' Set color to write OUT &H3C9, red% ' write red value OUT &H3C9, grn% ' write green value OUT &H3C9, blu% ' write blue value NEXT LOOP WHILE done% <> 0 CASE "FADEOUT" DO visible% = 0 FOR colour% = 0 TO 255 OUT &H3C7, colour% ' Set color to read red% = INP(&H3C9) ' read red value grn% = INP(&H3C9) ' read green value blu% = INP(&H3C9) ' read blue value ' Test the color values, decrementing if necessary. ' Set loop variable if colors are still visible. IF red% > 0 THEN red% = red% - 1: visible% = 1 IF grn% > 0 THEN grn% = grn% - 1: visible% = 1 IF blu% > 0 THEN blu% = blu% - 1: visible% = 1 WAIT &H3DA, 8, 8 OUT &H3C8, colour% ' Set color to write OUT &H3C9, red% ' write red value OUT &H3C9, grn% ' write green value OUT &H3C9, blu% ' write blue value NEXT LOOP WHILE visible% <> 0 CASE "RESTORE" FOR colour% = 0 TO 255 OUT &H3C8, colour% ' Set color to write OUT &H3C9, r(colour%) ' write red value OUT &H3C9, g(colour%) ' write green value OUT &H3C9, b(colour%) ' write blue value NEXT CASE "BLACKOUT" FOR colour% = 0 TO 255 OUT &H3C8, colour% ' Set color to write OUT &H3C9, 0 ' write red value OUT &H3C9, 0 ' write green value OUT &H3C9, 0 ' write blue value NEXT END SELECT END SUB SUB ParseCmdLine (cmd$, Params$(), Found%) 'This parsing sub does NOT mistake filenames like "F-14G.ZIP" as 'containing a switch. That's why it looks so big. Found% = FALSE: Sep$ = "-/": Temp$ = LTRIM$(RTRIM$(cmd$)): InParam% = FALSE FOR p% = 1 TO LEN(Temp$) C$ = MID$(Temp$, p%, 1) IF InParam% = TRUE THEN 'Inside of a switch? IF INSTR(Sep$, C$) THEN 'Found another switch? 'Terminate current switch, then start parsing the next one. GOSUB MakeParam: MID$(Temp$, p%, 1) = LEFT$(Sep$, 1) ParamStart% = p% ELSEIF ASC(C$) = 32 OR ASC(C$) = 9 THEN GOSUB MakeParam: InParam% = FALSE 'Terminate current switch. END IF ELSEIF InParam% = -2 THEN 'Inside of a parameter? IF ASC(C$) = 32 OR ASC(C$) = 9 THEN 'Terminate parameter with GOSUB MakeParam: InParam% = FALSE 'space or TAB. END IF ELSE IF INSTR(Sep$, C$) THEN 'Found start of a switch? 'Make sure all switches start with "-". MID$(Temp$, p%, 1) = LEFT$(Sep$, 1): InParam% = TRUE ParamStart% = p% ELSEIF ASC(C$) <> 32 AND ASC(C$) <> 9 THEN 'If char isn't a InParam% = -2: ParamStart% = p% 'space or TAB it's a parameter. END IF END IF NEXT IF InParam% THEN GOSUB MakeParam EXIT SUB MakeParam: Found% = Found% + 1 Params$(Found%) = MID$(Temp$, ParamStart%, p% - ParamStart%) IF Found% = UBOUND(Params$) THEN EXIT SUB RETURN END SUB SUB PressAnyKey STDOUT "Press any key to continue." + CHR$(13) ZX$ = INPUT$(1) STDOUT " " + CHR$(10) + CHR$(13) END SUB FUNCTION SelectTGAImageMode% (TGAFILE$) 'Test for Vesa Support before Anything DIM VESAX(1 TO 64) AS LONG SM2 = VARSEG(VESAX(1)): OS2 = VARPTR(VESAX(1)) ' Confirm VESA support and get pointer to list of supported VESA modes. ' Registers.AX = &H4F00 Registers.ES = CINT(SM2) Registers.DI = CINT(OS2) CALL InterruptX(&H10, Registers, Registers) DEF SEG = SM2 T$ = CHR$(PEEK(OS2)) + CHR$(PEEK(OS2 + 1)) + CHR$(PEEK(OS2 + 2)) + CHR$(PEEK(OS2 + 3)) DEF SEG IF T$ <> "VESA" THEN STDOUT "A Video Card with VESA support *IS REQUIRED* to use this Targa Image viewer." + CHR$(10) + CHR$(13) SelectTGAImageMode = -2: 'No Vesa Support EXIT FUNCTION END IF ERASE VESAX 'Test Tga File ON ERROR GOTO HandleErrors OPEN (TGAFILE$) FOR BINARY AS #1 IF LOF(1) = 0 THEN CLOSE : KILL TGAFILE$: Ingraphics = 0: ERROR 77 GET #1, 1, HDR: CLOSE #1 'BSCREEN 0, 0, 0, 0 'PRINT ASC(HDR.Clr), ASC(HDR.Img): SLEEP 'PRINT ASC(HDR.Pix): : SLEEP: STOP IF ASC(HDR.Clr) > 1 OR ASC(HDR.Img) > 2 THEN BSCREEN 0, 0, 0, 0 STDOUT "Possible Reasons why this will not work:" + CHR$(10) + CHR$(13) STDOUT "1) Unable to load TGA file." + CHR$(10) + CHR$(13) STDOUT "2) Image may not be a TGA file." + CHR$(10) + CHR$(13) STDOUT "3) TGA compressed images are not supported." + CHR$(10) + CHR$(13) SelectTGAImageMode = -3: 'Can't load Targa Picture EXIT FUNCTION END IF STDOUT "Picture Info" + CHR$(10) + CHR$(13) STDOUT "Filename: " + TGAFILE$ + CHR$(10) + CHR$(13) STDOUT "Width:" + STR$(HDR.W) + " x " + "Height:" + STR$(HDR.H) + CHR$(10) + CHR$(13) STDOUT "Bits per pixel:" + STR$(ASC(HDR.Pix)) + CHR$(10) + CHR$(13) STDOUT "X origin point:" + STR$(HDR.XVal) + " x Y origin point:" + STR$(HDR.YVal) + CHR$(10) + CHR$(13) IF SeeInfo = TRUE THEN SLEEP 8 ' Get bits per pixel so image doesn't get screwed. IF ASC(HDR.Pix) = 24 THEN BPP = 24 ELSE BPP = 8 'Bits per Pixel ' Mode list ' MODE = 26: 640 x 400 x 256 ' MODE = 14: 640 x 480 x 256 ' MODE = 16: 800 x 600 x 256 ' MODE = 18: 1024 x 768 x 256 ' MODE = 20: 1200 x 1024 x 256 ' MODE = 22: 1600 x 1200 x 256 STI = FALSE 'Assume Worst Case - picture too big IF HDR.W >= 0 AND HDR.W <= 640 AND HDR.H >= 0 AND HDR.H <= 400 THEN SelectTGAImageMode = 26: STI = TRUE '640x400x256 IF HDR.W >= 0 AND HDR.W <= 640 AND HDR.H >= 401 AND HDR.H <= 480 THEN SelectTGAImageMode = 14: STI = TRUE '640x480x256 IF HDR.W >= 641 AND HDR.W <= 800 AND HDR.H >= 481 AND HDR.H <= 600 THEN SelectTGAImageMode = 16: STI = TRUE '800x600x256 IF HDR.W >= 801 AND HDR.W <= 1024 AND HDR.H >= 601 AND HDR.H <= 768 THEN SelectTGAImageMode = 18: STI = TRUE '1024x768x256 IF HDR.W >= 1025 AND HDR.W <= 1200 AND HDR.H >= 769 AND HDR.H <= 1024 THEN SelectTGAImageMode = 20: STI = TRUE '1200x1024x256 IF HDR.W >= 1201 AND HDR.W <= 1600 AND HDR.H >= 1025 AND HDR.H <= 1200 THEN SelectTGAImageMode = 22: STI = TRUE '1600x1200x256 IF STI = FALSE THEN SelectTGAImageMode = -4: ' Can't match an Image size to an available screen mode END IF END FUNCTION SUB STDOUT (MESSAGETEXT$) STATIC Registers.AX = &H4000 Registers.BX = &H1 Registers.CX = LEN(MESSAGETEXT$) Registers.DS = VARSEG(MESSAGETEXT$) Registers.DX = SADD(MESSAGETEXT$) CALL InterruptX(&H21, Registers, Registers) END SUB SUB SwitchBank (NB%) Registers.AX = &H4F05 Registers.BX = 0 Registers.DX = NB% CALL InterruptX(&H10, Registers, Registers) Bank% = NB% END SUB SUB TGALoad (File$) 'OPEN File$ FOR BINARY AS #1: GET #1, 1, HDR: CLOSE #1 ' IF ASC(HDR.Clr) <> 1 OR ASC(HDR.Img) <> 1 THEN ' BSCREEN 0, 0, 0, 0 ' STDOUT "Unable to load TGA file." + CHR$(10) + CHR$(13) ' EXIT SUB ' END IF ON ERROR GOTO HandleErrors OPEN File$ FOR BINARY AS #1 dcl% = HDR.Col * ASC(HDR.Bits) / 8: dcs& = 19 + ASC(HDR.Info) dce& = dcs& + dcl% SEEK #1, dcs& PB$ = SPACE$(3) FOR reg = 0 TO 255 GET #1, , PB$ IF SixteenMillionColors = FALSE THEN Rr = ASC(MID$(PB$, 3, 1)) \ 4: Gg = ASC(MID$(PB$, 2, 1)) \ 4 Bb = ASC(MID$(PB$, 1, 1)) \ 4 ELSE Rr = ASC(MID$(PB$, 3, 1)): Gg = ASC(MID$(PB$, 2, 1)) Bb = ASC(MID$(PB$, 1, 1)) END IF OUT &H3C8, reg: OUT &H3C9, Rr: OUT &H3C9, Gg: OUT &H3C9, Bb NEXT FOR BlackoutTest = 0 TO 255: OUT &H3C7, BlackoutTest Red1 = INP(&H3C9): Blue1 = INP(&H3C9): Green1 = INP(&H3C9) ColorExist& = Red1 + Blue1 + Green1 NEXT BlackoutTest IF ColorExist& = 0 OR ForceGrayScale = TRUE THEN IF BPP = 8 THEN GOSUB LoadLowGrayScale ELSE FOR GraySM = 0 TO 255 'Sixteen million Gray scale if needed OUT &H3C8, GraySM ' Set color to write OUT &H3C9, GraySM ' write red value OUT &H3C9, GraySM ' write green value OUT &H3C9, GraySM ' write blue value NEXT GraySM END IF END IF IF BPP = 24 AND ApplyEightBPPGScale = TRUE THEN GOSUB LoadLowGrayScale END IF PAL "SAVE" IF DisplayPictureWhileLoading = FALSE THEN PAL "BLACKOUT" END IF SEEK #1, dce& IF BPP = 24 THEN T$ = SPACE$(3) ELSE T$ = SPACE$(1) FOR YY = 0 TO HDR.H - 1 FOR XX = 0 TO HDR.W - 1 GET #1, , T$ IF BPP = 24 THEN IF BPP = 24 AND ApplyEightBPPGScale = TRUE THEN ByteColor& = ASC(MID$(T$, 3, 1)) \ 3 + ASC(MID$(T$, 2, 1)) \ 3 + ASC(MID$(T$, 1, 1)) \ 3 ELSE ByteColor& = ASC(MID$(T$, 3, 1)) \ 3 + ASC(MID$(T$, 2, 1)) \ 3 + ASC(MID$(T$, 1, 1)) \ 3 END IF IF ByteColor& > 32767 THEN ByteColor& = ByteColor& \ 2 'STDOUT STR$(ByteColor) ELSE ByteColor& = ASC(T$) END IF DPSET XX, YY, CINT(ByteColor&) Abort$ = INKEY$ IF Abort$ = CHR$(27) THEN CLOSE BSCREEN 0, 0, 0, 0 STDOUT "TGA image loading aborted !" + CHR$(10) + CHR$(13) END END IF NEXT XX NEXT YY IF DisplayPictureWhileLoading = FALSE THEN PAL "FADEIN" END IF CLOSE #1 EXIT SUB LoadLowGrayScale: RESTORE GrayTFSC FOR GrayTFS = 0 TO 255 READ Red2, Blue2, Green2 OUT &H3C8, GrayTFS ' Set color to write OUT &H3C9, Red2 ' write red value OUT &H3C9, Green2 ' write green value OUT &H3C9, Blue2 ' write blue value NEXT GrayTFS RETURN END SUB SUB WriteSuperVgaRaw (SRWName$) ON ERROR GOTO HandleErrors OPEN SRWName$ FOR OUTPUT AS #1 PRINT #1, "SuperVGA_TGA_viewerSuperRWformat"; FOR PalSave = 0 TO 255 OUT &H3C7, PalSave ' Set color to read PRINT #1, CHR$(INP(&H3C9)); ' read red value PRINT #1, CHR$(INP(&H3C9)); ' read green value PRINT #1, CHR$(INP(&H3C9)); ' read blue value NEXT PalSave ' Mode list ' MODE = 26: 640 x 400 x 256 ' MODE = 14: 640 x 480 x 256 ' MODE = 16: 800 x 600 x 256 ' MODE = 18: 1024 x 768 x 256 ' MODE = 20: 1200 x 1024 x 256 ' MODE = 22: 1600 x 1200 x 256 SELECT CASE VesMode CASE IS = 26: H = 639: V = 399 CASE IS = 14: H = 639: V = 479 CASE IS = 16: H = 799: V = 599 CASE IS = 18: H = 1023: V = 767 CASE IS = 20: H = 1199: V = 1023 CASE IS = 22: H = 1599: V = 1199 END SELECT FOR VPIX = 0 TO V FOR HPIX = 0 TO H PIXELCOLOR = DPOINT(HPIX, VPIX) PRINT #1, CHR$(PIXELCOLOR); NEXT HPIX, VPIX CLOSE END SUB SUB XBeep (High, Low, Duration) STATIC OUT 97, INP(97) OR &H3: OUT 67, 182 OUT 66, High: OUT 66, Low FOR Z! = 0 TO Duration: NEXT Z! OUT 97, INP(97) AND &HFC END SUB