Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 TIM files
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Brightguy




PostPosted: Sun May 30, 2004 5:42 am   Post subject: TIM files

The Turing IMage File... it seems like a very awkward format. Unfortunately I'm doing a project in good ol' DOS Turing, and I don't know of any other method to load images. In the past, I've had troubles with colours being distorted when I try to display the image, so this time I'm using a basic 2-colour image. I can get it to display, but for unknown reasons, it won't display if I change the x-value of where to place the image on the screen. It only displays when the x-value is 0. Any one here ever work with TIM files before? Here's the code to read the file...
code:
var maxArray := 8000

% Procedure to read a TIM file and write it to the screen
procedure fileToScreen (x, y : int, fName : string, var ok : boolean)
        var Y := y
        var pic : array 1 .. maxArray of int
        var fs : int

        open : fs, fName, read
        ok := fs > 0
        if not ok then
            return
        end if
        var bytesToRead, bytesRead : int
        loop
            exit when eof (fs)
            read : fs, bytesToRead
            read : fs, pic : bytesToRead : bytesRead
            drawpic (x, Y, pic, 0)
            Y += pic (1) + 1
        end loop
        close : fs
end fileToScreen
Sponsor
Sponsor
Sponsor
sponsor
Delta




PostPosted: Sun May 30, 2004 6:58 am   Post subject: (No subject)

Wow dude! Hats off to you. Poor guy. Why are you still using classic turing? Seriously do yourself a favour and get WinOOT at least. Man oh man. lol.

Well anyways. Now that that's over and done with. Oh ya, your problem. I've never used .TIM files but right off the bat I know your problem (*Whispers : Your using dos turing*) Buts thats ok I guess.

maybe this line has something to do with it
code:
drawpic (x, Y, pic, 0)

because after all you are using an array, so therefore your should use an index of that array
for example :
code:
drawpic (x, Y, pic(1), 0)


but then again you'd get an error because that parameter doesn't call for an integer does it. Hmmmm. I tried finding a version of DOS turing, but I couldn't. I'll try again but ya I dunno. Well I really hate saying, but dude.... your on your own Sad
Delos




PostPosted: Sun May 30, 2004 4:38 pm   Post subject: (No subject)

Oh man...[lugs out ol' Classic Turing]...

Now what...oh rite...I need a TIM file!

Care to post one? Hopefully Delta already solved stuff for you...but in case, there still do exist other people with access to Classic Turing...sadly...
beard0




PostPosted: Sun May 30, 2004 5:25 pm   Post subject: (No subject)

I myself only upgraded to WinOOT this year, but I was using a newer old version of turing - see if the TM2 image type will work - here are the procedures for it:

code:
procedure FileToScreen (x, y : int, fileName : string)
    var version : int       
    var bufferSize : int   
    var xSize, ySize : int
    var screenWidth, screenHeight, screenColors : int
    var screenMode : string (11)
    var paletteUsed : int   
    var fs : int           
    open : fs, fileName, read
    if fs <= 0 then
        put "Unable to open file \"", fileName, "\" for reading."
        return
    end if
    read : fs, version
    if version not= 4661 then
        put "\"", fileName, "\" is not a legal TM2 file!"
        close : fs
        return
    end if
    read : fs, bufferSize
    read : fs, xSize, ySize
    read : fs, screenWidth, screenHeight, screenColors, screenMode
    read : fs, paletteUsed
    if paletteUsed = 1 then
        var numColours : int
        var red, green, blue : array 1 .. 256 of int
        read : fs, numColours
        if maxcolour not= numColours - 1 then
            put "The image contains a palette with ", numColours
            put "colours, while the current graphics mode supports "
            put maxcolour + 1, " colours.  You are probably in a"
            put "different graphics mode from the one that this"
            put "picture was created in."
            close : fs
            return
        end if
        for cnt : 1 .. numColours
            read : fs, red (cnt), green (cnt), blue (cnt)
        end for
        setcolourmap (red, green, blue, numColours)
    end if
    var pic : array 1 .. bufferSize of int
    var bytesToRead, bytesRead : int
    var currentY : int
    currentY := ySize + y
    loop
        exit when eof (fs)
        read : fs, bytesToRead
        read : fs, pic : bytesToRead : bytesRead
        if bytesToRead not= bytesRead then
            put "\"", fileName, "\" ended in the middle of an image.  This"
            put "probably means the image was damaged."
            return
        end if
        currentY -= pic (1) + 1
        drawpic (x, currentY, pic, 0)
    end loop
    close : fs
end FileToScreen

procedure ScreenToFile (x1, y1, x2, y2 : int, fileName : string)
    var version : int
    var bufferSize : int := 1000
    var xSize, ySize : int
    var screenWidth, screenHeight, screenColors : int
    var screenMode : string (11)
    var paletteUsed : int
    var fs : int
    open : fs, fileName, write
    if fs <= 0 then
        put "Unable to creat file \"", fileName, "\"."
        return
    end if
    version := 4661
    write : fs, version
    write : fs, bufferSize
    xSize := abs (x2 - x1) + 1
    ySize := abs (y2 - y1) + 1
    write : fs, xSize, ySize
    screenWidth := maxx + 1
    screenHeight := maxy + 1
    screenColors := maxcolor + 1
    if screenWidth = 320 then
        if screenColors = 4 then
            screenMode := "cga"
        elsif screenColors = 16 then
            screenMode := "16"
        else
            screenMode := "mcga"
        end if
    elsif screenWidth = 640 then
        if screenHeight = 200 then
            if screenColors = 2 then
                screenMode := "hmono"
            else
                screenMode := "h16"
            end if
        elsif screenHeight = 350 then
            screenMode := "ega"
        elsif screenHeight = 400 then
            screenMode := "svga1"
        else
            if screenColors = 2 then
                screenMode := "v2"
            elsif screenColors = 16 then
                screenMode := "vga"
            else
                screenMode := "svga"
            end if
        end if
    elsif screenWidth = 800 then
        if screenColors = 16 then
            screenMode := "svga3"
        else
            screenMode := "svga4"
        end if
    else
        if screenColors = 16 then
            screenMode := "svga5"
        else
            screenMode := "svga6"
        end if
    end if
    write : fs, screenWidth, screenHeight, screenColors, screenMode
    paletteUsed := 0
    write : fs, paletteUsed
    var pic : array 1 .. bufferSize of int
    var bytesToWrite, bytesWritten : int
    var currentY : int
    var numRowsInChunk : int
    const topRow := max (y1, y2)
    const bottomRow := min (y1, y2)
    numRowsInChunk := (bufferSize - 3) div sizepic (x1, 1, x2, 1)
    currentY := topRow + 1
    loop
        exit when currentY - numRowsInChunk <= bottomRow
        currentY -= numRowsInChunk
        takepic (x1, currentY, x2, currentY + numRowsInChunk - 1, pic)
        bytesToWrite := sizepic (x1, 0, x2, numRowsInChunk - 1) * 4
        write : fs, bytesToWrite
        write : fs, pic : bytesToWrite
    end loop
    takepic (x1, bottomRow, x2, currentY - 1, pic)
    bytesToWrite := sizepic (x1, bottomRow, x2, currentY - 1) * 4
    write : fs, bytesToWrite
    write : fs, pic : bytesToWrite
    close : fs
end ScreenToFile
Brightguy




PostPosted: Wed Jun 02, 2004 5:12 pm   Post subject: Re: TIM files

Thanks for your help, but I'm using 7.05A and the TM2 files don't seem to work. A workaround to this problem which I'm using is to display the image when the program loads, and store it with takepic. Then I can display it wherever I want with drawpic. I still don't know why fileToScreen doesn't work properly. By the way, my school actually has OOT, but my teacher is worried about using the parallelport on the new computers. Rolling Eyes
McKenzie




PostPosted: Fri Jun 04, 2004 2:31 pm   Post subject: (No subject)

I think TM2 came out in 8.0, this should be a free upgrade from 7.x (if I recall). hmmm... just came back from the holt site, can't find the upgrade.
Why is your teacher concerned about the parrallel port?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: