VGA Graphics?

DOS specific questions.
davidshq
Posts: 52
Joined: Oct 29, 2008 3:28
Contact:

VGA Graphics?

Post by davidshq »

I have an old QuickBasic 4.5 game and it utilizes some graphics with a .vga extension. Was wondering if anyone might know how to open/convert these images? Or even what kind of images they are?
Dave.
stylin
Posts: 1253
Joined: Nov 06, 2005 5:19

Post by stylin »

I could not find anything on google or www.wotsit.org on .vga files, maybe someone else knows. Your best bet would probably be to look at the source, or try and contact the author (if you know who it is).

As a last resort you can try and figure out the format yourself, if you don't get any other responses here.
davidshq
Posts: 52
Joined: Oct 29, 2008 3:28
Contact:

Post by davidshq »

Thanks for the suggestions. I did look at the source and it appears the developer is just using a BLOAD? I'd think there would need to be some special parsing, but I'm not seeing any.
Dave.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

How big are these files?
DOS386
Posts: 798
Joined: Jul 02, 2005 20:55

Re: VGA Graphics?

Post by DOS386 »

davidshq wrote:old QuickBasic 4.5 game and it utilizes some graphics with a .vga extension.
Reveal size or upload it. I guess it's a raw copy of VGA RAM.
there would need to be some special parsing, but I'm not seeing any.
Because it's raw :-D
davidshq
Posts: 52
Joined: Oct 29, 2008 3:28
Contact:

Post by davidshq »

There are a number of different files, this one specifically is around 3 KB in size. If it is raw how does one open it using a modern application? :) I just want to open the file and perhaps be able to edit it and save it as a JPG, etc. Thoughts?
Dave.
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Post by counting_pine »

Well, you could try something like the following in QB:

Code: Select all

SCREEN 13
DIM a%(10000)
DEF SEG = VARSEG(a%(0))
BLOAD "graphic.vga", VARPTR(a%(0))
PUT (0, 0), a%(0)
If it works, then you could try PrintScreening, or we could export the data in a form that's easy for FB to read.

Alternatively, more information about the file really would be helpful.
This little program will give the exact file size and the first 32 bytes, which might be enough to glean the format from if you paste it here.

Code: Select all

DIM c AS STRING
c = " "
OPEN "graphic.vga" FOR BINARY AS #1


    PRINT "File size:"; LOF(1)

    PRINT "First 32 bytes:"
    FOR i = 1 TO 100
        GET #1, , c
        PRINT HEX$(ASC(c)) + " ";
    NEXT i

CLOSE #1
(obviously, adjust the file names to suit.)

If we can extract the image data, probably the easiest format to work with will be BMP, because FB can load and save them natively. JPEG would be a bad choice of format here because it uses lossy compression, which degrades the image quality.

EDIT: Sorry, code fixed now, DOS386's fix was entirely accurate. I wrote both sections of code in QBASIC (I missed the dollar in my hasty fix-up for FB), and the "GET #1, 1, ..." was just careless. I'm guessing DOS386 and I both thought exactly the same thing when we saw the repeated FD in the output...
Last edited by counting_pine on Oct 30, 2008 9:38, edited 2 times in total.
davidshq
Posts: 52
Joined: Oct 29, 2008 3:28
Contact:

Post by davidshq »

I ran the second app. Here are the results:
File size: 3135
First 32 bytes:
FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD
FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD F
D FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD
FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD

Dave.
DOS386
Posts: 798
Joined: Jul 02, 2005 20:55

Post by DOS386 »

davidshq wrote:Thoughts?
1. Use BMP or PNG for new format (see above)
2. Upload the corpus delicti or post a few bytes from the beginning (see above) or post QB code or do a screenshot using SNARF
DOS386
Posts: 798
Joined: Jul 02, 2005 20:55

Post by DOS386 »

davidshq wrote:FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD
FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD F
D FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD
FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD FD
counting_pine's code is buggy:

Code: Select all

Get #1, 1, c
->

Code: Select all

Get #1, , c
and the dollar "$" ...

http://www.freebasic.net/wiki/KeyPgBload

It's QB's BSAVE file :-)))
davidshq
Posts: 52
Joined: Oct 29, 2008 3:28
Contact:

Post by davidshq »

Okay, made those changes to the code and reran. Here are the new results:
File size: 3135
First 32 bytes:
FD 27 9F 0 0 38 C 29 0 41 0 0 0 0 0 0 0 FF FF FF FF FF 80 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 FF FF FF FF FF 80 0 0 0 0 0 0 0 3 FF F8 0 0 0 0 0 0 0 0 FF FE 0 7
FF 80 0 0 0 0 0 0 0 4 0 0 0 0 0 1 FF F8 0 0 FF FC 0 3 FF 80 0 0 0 0 0

What I want to do is convert this raw file to a BMP file.
Dave.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

The file looks like a bsaved image. Try bloading it in QB as counting_pine suggested.
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Post by counting_pine »

If the first program works, then you can output the raw contents of the screen to a text file, by appending this code to the program:

Code: Select all

OPEN "graphic.txt" FOR OUTPUT AS #1
    FOR y = 0 TO 199
        FOR x = 0 TO 319
            PRINT #1, POINT(x, y);
        NEXT x
        PRINT #1,
    NEXT y
CLOSE #1
Then, you can convert that data to a BMP file in FB with this program:

Code: Select all

dim as integer x, y, c

screen 13

open "graphic.txt" for input as #1
    for y = 0 to 199
        for x = 0 to 319
            input #1, c
            pset (x, y), c
        next x
    next y
close #1

bsave "graphic.bmp", 0
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Post by counting_pine »

I don't know if you had any luck with this, but from looking at the first portion of the file, and from the little I know about BSAVEd files, this program should be able to load the image.
It should compile and run (just about...) in both QB and FB, and if you uncomment a few lines in FB, it should automatically save the image as a BMP as well.

Code: Select all

declare sub putplane (y as integer, w as integer, bb as integer)
dim c as string
dim z as integer, w as integer, h as integer
dim y as integer, b as integer

screen 13

open "graphic.vga" for binary access read as #1
    
    c = " "
    get #1, 1, c
    if asc(c) <> &HFD then close #1: end
    get #1, 6, z: z = z and 32767
    get #1, 8, w: w = w and 32767
    get #1, 10, h: h = h and 32767
    seek #1, 12

    for y = 0 to h - 1
        for b = 0 to 3
            putplane y, w, 2 ^ b
        next b
    next y
    
close #1
sleep

'uncomment these lines in FB to save the image as a bmp:
'dim as any ptr p = imagecreate(w, h)
'get (0, 0)-(w-1, h-1), p
'bsave "graphic.bmp", p, 0
'imagedestroy p

sub putplane (y as integer, w as integer, bb as integer)

    dim c as string, cb as integer
    dim x as integer
    c = " "

    for x = 0 to w - 1
        if (x and 7) = 0 then get #1, , c: cb = asc(c)

        pset (x, y), point(x, y) xor (bb and -cb \ 128)

        cb = cb + cb and &HFF
    next x

end sub
davidshq
Posts: 52
Joined: Oct 29, 2008 3:28
Contact:

Post by davidshq »

Now that I disappeared for two years...I used the above code and it worked wonderfully....except for one minor detail...the images are much smaller than they used to be once they are saved as BMP...any thoughts? I'm guessing since its a screen capture it might be an issue with it capturing the image at a higher resolution?
Dave.
Post Reply