Okay so I hope this is the right place to put this. But onto the point.

Anyway a long time ago my father showed me a game he used to play called Adventure. Some right remember this command prompt game as well as it's opening words "YOU ARE STANDING AT THE END OF A ROAD BEFORE A SMALL BRICK BUILDING..."

Well awhile back I actually found what I believe to be was the source code for the game. If I remember right they had found Will Crowther's source on an older server.

The files can be found here:
http://jerz.setonhill.edu/if/crowther/

Now here's the problem. I have no clue how to interpret these files. I was hoping to convert this to C using f2C, but I don't even know where to start. I believe the that some of these files are later versions of others, but have no clue what to do with what.

For instance, I believe "advf4.77-03-31" contains the final version of the game while "advdat.77-03-31" contains all the strings to the game. But that's about as far as I can get. I believe I got f2c installed properly on my Centos machine, but again, I have no clue how to prepare these files for use, or even if they can be converted because I don't understand Fortran well enough.

Any help would be greatly appreciated, and please don't just link me to a website unless it's really good. I can Google all I want for tutorials, but some a personal touch can offer a lot more understand then a generic web site tutorial

Long time ago I've seen some FORTRAN code!
My knowledge about it has become very hazy.
I still know, that every line starting with a C is a comment and any variable starting with I,J,K,L,M,N is an integer. That's why we all still have the habbit of using i,j,k etc. as loop counters!

LOL oh really? that's to rich about the variables.

Know any other tricks? I mean the one file with all the strings, how exactly would that translate over? If I have to, I'll convert this by hand, but I really would need to learn some more about Fortran before I do

I also noticed that the file "advdat.77-03-31" has different sections, marked with -1 (EOF ?)
Could it be, it are different files merged together here for conveniance of storage?
Lines starting with the same number here, obviouly form one string(in the first section anyway)
These data get read in at the beginning of the program into some arrays, but for the moment I have no further clues.

You are on to something about that EOF I think. The reason this file caught my eye is when using IDA-Pro to reverse engineer .exes, a lot of times, if not all the time, the strings are in their own part of code, and then are refenced to by the assembly code.

Now granted yes it's assembly, but I feel it's the same concept.

I also think you are right about loading in the words. I caught the value "3079 F%^)" (I censored it), which I remember typing into the game once and the game replied with some comment.

Well I didn't find a number reference in the code itself, to 3079, or even the previous entry which is THROW, which is also used. So this makes me agree with you that they are loaded in.

Now what I need to figure out is these extensions to the files. "77-03-31" can't be the proper extension can it? I thought Fortran used .f? Also I ask because I seem to have duplicates of each file, so I am wondering, are these dates? So I have been given different versions of the files?

It is indeed a date 1977 march 31. The date is reversed, it was and still is I think, a tric to sort files by date. The file are I guess no duplicates but updates of a later date, with perhaps some small changes here and there (bug fixes?).

Yep that's what I was thinking as well, but wasn't sure. I was thinking maybe this was some weird format used (since it seems this is written in Fortran77, well maybe, not entirely sure).

Anyway I have begun my attempts with f2c to see if I can convert the files, no luck so far

And then to know that Fortran77 was written in C!!! Click Here

LOL yep. That's why I have been using f2c to try and convert my code (why they couldn't just go straigh to C, I don't know). Ran into a problem though.

f2c doesn't know how the handle the following line (and there are more like it down the line)

TYPE 67,DTOT

I have a basic idea of how it works, but not completely. I think it's used for like declaration or what not, and want to convert TYPE to like Integer or Real or what not ... problem is, not sure haw 67 will work with it

TYPE is the same as PRINT. 67 is a format specifier DTOT is some variable with a total?
I found info here

Took me awhile but I came to a similar conclusion, except I found it here

Now I just need to figure out how exactly to convert the statement over to PRINT (my pulled teeth are saying otherwise and trying to force me back to bed).

UPDATE: Looks like I can simply rename TYPE to PRINT to fix it. Well at least f2c is happy with it (if I can just get a basic almost complete convert of this code, I think it should be fixable in C .... I think!)

Well, before going to bed myself I like to send you this Has some good tips in it on how to proceed, I think.
See ya!

I'll assume your off, but I'll ask this one more before I call it for now. I have been scratching my head for ever on this one. I need to find a way to have Fortran compare a string.

It's telling me there's an illegal comparison which makes me think it's comparing like an integer to a string. So now I am trying to figure out, how exactly would I convert a string to an int ... if that's what it's trying to do

Here's some of the statements I need to fix

IF(A.EQ.'ENTER'.AND.(WD2.EQ.'STREA'.OR.WD2.EQ.'WATER'))GOTO 2010

IF(A.EQ.'ENTER'.AND.TWOWDS.NE.0)GOTO 2012

IF(A.NE.'WEST')GOTO 2023

I just can't seem to find a way to crack this one. I see stuff about Fortran 90 supporting functions to do items like this, but seeing as f2c is kind of meant to work with Fortran 77, and that's what I am converting from, I pretty much have to rule out 90.

Also I should point out that I'm pretty sure it is the string part, as I have fixed earlier ones by using ichar() ... of course that's limited only to a char and not an array of chars

Well I'll add to the list of items I am having trouble with. Currently it's Octal Constants.

It seems that in Fortran 77, they were represented with a double quote (") in front. I have multiple statements that use them in the code, and have no clue what they are or how to handle them

IF (RES.LT.0) J="200000000000

RES = ((RES.AND."377777777777)/2) + J

IF ((RES.AND."200000000000).NE.0) J="400000000000

RES = (RES.AND."177777777777)*2 + J

IF(J.EQ.1) B=(B.AND.-M2(K)).OR.("201004020100.AND.(-M2(K).XOR.-1))

If someone could explain to what exactly these do, or how to fix it so the f2c converter can accept it, I would be appreciative

From Wikipedia octal:

Octal became widely used in computing when systems such as the PDP-8, ICL 1900 and IBM mainframes employed 12-bit, 24-bit or 36-bit words. Octal was an ideal abbreviation of binary for these machines because their word size is divisible by three (each octal digit represents three binary digits). So four, eight or twelve digits could concisely display an entire machine word. It also cut costs by allowing Nixie tubes, seven-segment displays, and calculators to be used for the operator consoles, where binary displays were too complex to use, decimal displays needed complex hardware to convert radices, and hexadecimal displays needed to display more numerals.

Btw. a Nixie tube is like the tubes you could find in an old pre-transistor radios. It can display(let glow) the digits 0 to 9.
You can find many conversion routines on the web to change between binary,octal,decimal and hexadecimal numbers.
377777777777(octal) = 34359738367(decimal) which exeeds an int32, so use int64.

==============================================================================
IF statemenets:

IF(A.EQ.'ENTER'.AND.(WD2.EQ.'STREA'.OR.WD2.EQ.'WATER'))GOTO 2010

I would translate it as(hope my C is still OK)
If( A == "ENTER" && (WD2 == "STREA" || WD2 == "WATER") goto 2010
A and WD2 appear to be strings, so I cannot see what would be wrong here.
Altough The IMPLICI statment in the beginning of the program indicates A and WD2 to be integers.
Is this changed somewhere?

Actually I managed to fix both of these after more and more searching.

So let get get this straight, Octals were kind of like an early version of Hexidecimal you might say? (BTW I think I managed to fix these for f2c to convert by doing something like changing "201004020100 to O"201004020100").

I also was able to finally fix the IF statements. It had to deal with how they were ordered, and how AND and what not was being used used.

For instance the line

IF(J.EQ.1) B=(B.AND.-M2(K)).OR.("201004020100.AND.(-M2(K).XOR.-1))

Had to be rewritten as (with the octal constant fix)

IF(J.EQ.1) B=IOR((IAND(B,-M2(K))),(IAND(O"201004020100",(XOR(-M2(K),-1)))))

I am still a little worried the XORs might not have converted properly, but I'll check that.

Last but not least, was comparing strings. I had no clue how to go about fixing this for f2c to accept it and convert the file, so instead I simply created numerical values for each word, were A=1, B=2, ext, and then simply replaced the strings with numbers. This is a temporary fix, where I hope to convert them back to strings once it's in C

Well anyway, thanks for the help ddanbe, not only was this fun to look into Fortran and learn a few things, but a nice challange to try and fix everything. We'll see how that C file turned out (it's sitting open on my desktop now, and I am about to look at it ... drum roll please)

Glad to be of some help. It was fun for me to relive the past a bit!
Let me know if it succeeded.
Any more question? Just start a new thread, be happy to answer (if I can :) )

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.