cflow

This is just me rambling……

Anyways I was looking at some source, and instead of me trying to make heads or tails of it, it’d be more fun to have the machine try to do so, and in this endeavor I thought I’d try cflow.

So let’s try something terribly simply, like the fortune program from Unix 32v:

#include stdio.h

char line[500];
char bline[500];

main()
{
        double p;
        register char * l;
        long t;
        FILE *f;

        f = fopen("/usr/games/lib/fortunes", "r");
        if (f == NULL) {
                printf("Memory fault -- core dumped\n");
                exit(1);
        }
        time(&t);
        srand(getpid() + (int)((t>>16) + t));
        p = 1.;
        for(;;) {
                l = fgets(line, 500, f);
                if(l == NULL)
                        break;
                if(rand() < 2147483648./p)
                        strcpy(bline, line);
                p += 1.;
        }
        fputs(bline, stdout);
        return(0);
}

This is a simple program, to say the least.  So running cflow gives me this:

# cflow fortune.c
main() :
    fopen()
    printf()
    exit()
    time()
    srand()
    getpid()
    fgets()
    rand()
    strcpy()
    fputs()

Simple, right?  Now let’s add in the C pre-processor, and add in the 32v include paths….

# cflow --cpp='/usr/bin/cpp -nostdinc -I../../include -I../../include/sys -I.' -n fortune.c
    1 main() :
    2     fopen()
    3     printf()
    4     exit()
    5     time()
    6     srand()
    7     getpid()
    8     fgets()
    9     rand()
   10     strcpy()
   11     fputs()

OK same thing, I can’t say I was expecting anything else.  But now let’s add in libc:

# cflow --cpp='/usr/bin/cpp -nostdinc -I../../include -I../../include/sys -I.' -n fortune.c ../libc/gen/*.c ../libc/stdio/*.c
    1 main() [main () at ../libc/gen/ttytest.c:2]:
    2     fopen() [struct _iobuf fopen (file, mode) at ../libc/stdio/fopen.c:5]
    3     printf() [printf (fmt, args) at ../libc/stdio/printf.c:3]:
    4     exit()
    5     time()
    6     srand()
    7     getpid()
    8     fgets() [char *fgets (s, n, iop) at ../libc/stdio/fgets.c:4]
    9     rand() [rand () at ../libc/gen/rand.c:9]
   10     strcpy()
   11     fputs()
   12     ttyname() [char *ttyname (f) at ../libc/gen/ttyname.c:17]:
   13         isatty() [if (isatty (( & _iob[1]) _file)) at ../libc/stdio/flsbuf.c:24]:
   14             gtty() [gtty (fd, ap) at ../libc/gen/stty.c:13]:
   15                 ioctl()
   16         fstat()
   17         open()
   18         read()
   19         strcpy()
   20         strcat()
   21         stat()
   22         close()

Isn’t that cool?  Now what does the kernel do?

I went ahead and renamed the main function call in the 32v kernel so that way it doesn’t mesh the main’s but here is the call flow:

    # cflow --cpp='/usr/bin/cpp -nostdinc -I../../include -I../../include/sys -I.' -n  fortune.c ../libc/gen/*.c ../libc/stdio/*.c ../sys/sys/*.c
    1 main() [main () at ../libc/gen/ttytest.c:2]:
    2     fopen() [struct _iobuf fopen (file, mode) at ../libc/stdio/fopen.c:5]
    3     printf() [printf (fmt, args) at ../libc/stdio/printf.c:3]:
    4     exit() [exit (rv) at ../sys/sys/sys1.c:343]:
    5         closef()
    6         plock()
    7         iput()
    8         xfree() [xfree () at ../sys/sys/text.c:127]
    9         acct() [acct () at ../sys/sys/acct.c:51]:
   10             plock()
   11             compress()
   12             writei()
   13             prele()
   14         memfree()
   15         wakeup()
   16         setrun()
   17         swtch() [swtch () at ../sys/sys/slp.c:417]:
   18             save() [if (save (u u_ssav)) at ../sys/sys/text.c:253]
   19             resume()
   20             spl6()
   21             idle()
   22             spl0()
   23     srand()
   24     getpid() [getpid () at ../sys/sys/sys4.c:120]:
   25     fgets() [char *fgets (s, n, iop) at ../libc/stdio/fgets.c:4]
   26     rand() [rand () at ../libc/gen/rand.c:9]
   27     strcpy()
   28     fputs()
   29     ttyname() [char *ttyname (f) at ../libc/gen/ttyname.c:17]:
   30         isatty() [if (isatty (( & _iob[1]) _file)) at ../libc/stdio/flsbuf.c:24]:
   31             gtty() [gtty () at ../sys/sys/tty.c:90]:
   32                 ioctl() [ioctl () at ../sys/sys/tty.c:102]:
   33                     getf()
   34         fstat() [fstat () at ../sys/sys/sys3.c:18]:
   35             getf()
   36             stat1()
   37         open() [open () at ../sys/sys/sys2.c:80]
   38         read() [read () at ../sys/sys/sys2.c:12]:
   39             rdwr()
   40         strcpy()
   41         strcat()
   42         stat() [stat () at ../sys/sys/sys3.c:36]:
   43             namei() [struct inode namei (func, flag) at ../sys/sys/nami.c:21]
   44             uchar() [uchar () at ../sys/sys/nami.c:216]:
   45                 fubyte()
   46             stat1()
   47             iput()
   48         close() [close () at ../sys/sys/sys2.c:163]

For something more aggressive, check out the QuakeWorld Server, and UAE 0.4

I found the source to Mach 2.5

And an i386 port dating back to 1989!

Browsable CVS source is on my ‘unix’ site.

Or for anyone who cares, you can download the compressed MACH_CSRG_CD.7z .

I haven’t tried to build it, but I also see SUN2/3 hardware support, lots of bug fixes from NeXT, but no NeXT hardware support.  Also the VAX platform is in there as well.

*EDIT as an update from the future, I ended up getting disk images to Mach/386 and using that as a build system I was in fact able to build the Mach 2.5 i386 images!

Read about that adventure in Mach 2.5 Independence day.

Capstone source archive

I came across this fun page, which has the source code for a variety of games from the now defunct Capstone Software company.

For a while they licensed the build engine to pump out a few games, namely:

Pretty cool!

Corridor 8 was never finished so this is more so in the Alpha stage using many DooM assets.

I haven’t had time to try them out, but I thought I’d share the links as it were.

OpenNT – Windows NT 4.5

(This is a guest post from Tenox)

Just stumbled across this: someone has forked Windows NT 4.0 and created an open source version of it. But wait, forked what? Windows source code doesn’t live on Github. Is it ReactOS? No! Upon some digging, it was apparently born from the leaked source code of NT4.0, some W2K bits and 2003 WRK…

Enter NT version 4.5:

NT45Test-2015-04-27-18-20-37More screenshots here: http://www.opennt.net/projects/opennt/wiki/Screenshots

The main project site: http://www.opennt.net/

Looking at activity the project seems to be alive and well. There is some background information and discussion going on BetaArchive for those interested.

I wonder what Microsoft has to say about this 🙂

EDIT* for those from the future, you may be interested in this followup – OpenNT 4.5 revisited, where it’s compiled and run!

So yeah, sourceforge is still down

sourceforge down

Kind of annoying when I wanted to expand something with mingw, and all their download mirrors are… sourceforge.  And since I finally got around to putting Cockatrice on git but where did I put it? sourceforge.

Seems everyone has a good outage from time to time.  What to do?  Trust more of the cloud?

On Saturday 11AM BST the pages and downloads are back online!

Project pages and downloads back online!

Project pages and downloads back online!

re-vamping source code cvs depot

I think it is kind of funny in a way I had set up unix.superglobalmegacorp.com years ago, but moved hosts a few times, and it broke all the CGI functionality.  But all the static pages still worked, so when googling around for internal stuff related to Quake, I would actually find my old site in the top five.

#5 for Sys_FileOpenWrite

#5 for Sys_FileOpenWrite

So, I thought I’d take some time, and get it working again.  I use two programs CVSweb, and src2html.

CVSweb let’s you easily explore multiple revisions, do comparisons between the versions, and just look all around great. I keep a copy of the following:

  • Net/2 This also includes Net/2 derived OS’s 386BSD 0.0 and 0.1, and NetBSD 0.8/0.9
  • DOOM Includes, Heritic, and Hexen
  • truecrypt, the popular disk encryption tool
  • Synchronet the BBS software for MS-DOS, OS/2, Win32 and Linux/BSD
  • Quake, the popular game from iD.
  • QuakeWorld, the multiplayer version of Quake
  • Quake II, the successor to Quake.

I also like how the src2html program parses out the code so you can search for symbols in the code.  However src2html works with static versions of the code, not CVS, so I selected various programs to be available, some from above, and:

So it may not be worth much to most users, but when looking to see how various code works, it’s really useful.  Of course none of this compares to Visual Studio’s search database, but google has to learn from somewhere.

I should also point out that upgrading perl as part of a move from Debian 7 to Debian 8 broke CVS web.  Thankfully the NetBSD folk had a simple 2 line fix!

— cvsweb.orig 2013-12-24 09:58:09.333520125 -0500
+++ cvsweb 2013-12-24 09:58:50.222171067 -0500
@@ -1194,7 +1194,7 @@

General options


EOF
– for my $v qw(hidecvsroot hidenonreadable) {
+ for my $v (qw(hidecvsroot hidenonreadable)) {
printf(qq{\n},
$v, $input{$v} || 0);
}
@@ -2953,7 +2953,7 @@
print ”
\n”;

print ‘‘;
– if (defined @mytz) {
+ if (@mytz) {
my ($est) = $mytz[(localtime($date{$_}))[8]];
print scalar localtime($date{$_}), ” $est
(“;
} else {

So it’s working again.

I saw this git/Unix archive mentioned on TUHS

And I thought that I should broadcast it to the world. Diomidis Spinellis has gone through the hard work of going through all the old legacy Unix source code, making it easily available here.  Even more fun it to just find somewhere with a couple of GB free, and clone it!

git clone https://github.com/dspinellis/unix-history-repo

With that done, you can then ‘check’ out the repo from any of the major releases and get the source!  For example to see 4.4 BSD, you would type in:

cd unix-history-repo
git checkout BSD-4_4

Pretty cool!

And it goes up to FreeBSD 10.0.1  Release tags are:

  • Epoch
  • Research-V1
  • Research-V3
  • Research-V4
  • Research-V5
  • Research-V6
  • BSD-1
  • BSD-2
  • Research-V7
  • Bell-32V
  • BSD-3
  • BSD-4
  • BSD-4_1_snap
  • BSD-4_1c_2
  • BSD-4_2
  • BSD-4_3
  • BSD-4_3_Reno
  • BSD-4_3_Net_1
  • BSD-4_3_Tahoe
  • BSD-4_3_Net_2
  • BSD-4_4
  • BSD-4_4_Lite1
  • BSD-4_4_Lite2
  • BSD-SCCS-END
  • 386BSD-0.0
  • 386BSD-0.1
  • FreeBSD-release/1.0, 1.1, 1.1.5
  • FreeBSD-release/2.0 2.0.5, 2.1.0, 2.1.5, 2.1.6, 2.1.6.1, 2.1.7, 2.2.0, 2.2.1, 2.2.2, 2.2.5, 2.2.6, 2.2.7, 2.2.8
  • FreeBSD-release/3.0.0, 3.1.0, 3.2.0, 3.3.0, 3.4.0, 3.5.0
  • FreeBSD-release/4.0.0 4.1.0, 4.1.1, 4.2.0, 4.3.0, 4.4.0, 4.5.0, 4.6.0, 4.6.1, 4.6.2, 4.7.0, 4.8.0, 4.9.0, 4.10.0, 4.11.0
  • FreeBSD-release/5.0.0 5.1.0, 5.2.0, 5.2.1, 5.3.0, 5.4.0, 5.5.0
  • FreeBSD-release/6.0.0, 6.1.0, 6.2.0, 6.3.0, 6.4.0
  • FreeBSD-release/7.0.0, 7.1.0, 7.2.0, 7.3.0, 7.4.0
  • FreeBSD-release/8.0.0, 8.1.0, 8.2.0, 8.3.0, 8.4.0
  • FreeBSD-release/9.0.0, 9.1.0, 9.2.0
  • FreeBSD-release/10.0.0, 10.1.0

Coherent sources released under a 3-clause BSD license

coherent

Print ad for Coherent

For those of you who’ve been living under a rock, or just not that familiar with what Coherent is, it’s a clean room re-implementation of version 7 Unix. What is unique about Coherent is that AT&T sent a team, which included Dennis Ritchie to evaluate the source to make sure that they hadn’t stolen Unix, and they concluded:

“that looking at various corners I couldn’t find anything that was copied.”

So Coherent was free to continue to sell their discount Unix like OS for the bargain price of $99 USD. I had plans on buying a copy as the older versions even supported the 8086, and 80286 however by the time I finally got enough RAM and disk space to make the purchase worth while, Linux was freely available. I believe that Coherent was the first OS to be killed by the Linux juggernaut, followed by SCO Xenix.

So it’s a little late to the party, open sourcing may have helped back in the early 1990’s although it’d seem like an utterly crazy move at the time.
Better late than never, this includes source dumps, and some RCS data, along with random tgz’s and a binary distribution of version 4. Without any doubt this will either help emulators better emulate the machine state Coherent expects, or perhaps fixing Coherent to run on more modern machines.

Coherent was also famous for it’s large, and well documented manual. Luckily the sources to the manual are also available.

So without further ado, here is the pages with the sources to coherent.

On final note of interest is that the Mark Williams Company was founded by Robert Swartz, who’s son Aaron was quite influential until the time of his death.

The complete archive for DOOM for the 3DO is on GitHub!

Link to the archive is here.

It’s a sizable download, 287MB, the majority being the ‘movies’ and ‘music’ directory.

 

The complete archive for DOOM for the 3DO
Yes, this is the infamous port of DOOM for the 3DO. Firstly, this was the product of ten intense weeks of work due to the fact that I was misled about the state of the port when I was offered the project. I was told that there was a version in existance with new levels, weapons and features and it only needed “polishing” and optimization to hit the market. After numerous requests for this version, I found out that there was no such thing and that Art Data Interactive was under the false impression that all anyone needed to do to port a game from one platform to another was just to compile the code and adding weapons was as simple as dropping in the art.

Uh… No…

My friends at 3DO were begging for DOOM to be on their platform and with christmas 1995 coming soon (I took this job in August of 1995, with a mid October golden master date), I literally lived in my office, only taking breaks to take a nap and got this port completed.

Shortcuts made…
I had no time to port the music driver, so I had a band that Art Data hired to redo the music so all I needed to do is call a streaming audio function to play the music. This turned out to be an excellent call because while the graphics were lackluster, the music got rave reviews.

3DO’s operating system was designed around running an app and purging, there was numerous bugs caused by memory leaks. So when I wanted to load the Logicware and id software logos on startup, the 3DO leaked the memory so to solve that, I created two apps, one to draw the 3do logo and the other to show the logicware logo. After they executed, they were purged from memory and the main game could run without loss of memory.

There was a Electronic Arts logo movie in the data, because there was a time that EA was going to be distributing the game, however the deal fell through.

The verticle walls were drawn with strips using the cell engine. However, the cell engine can’t handle 3D perspective so the floors and ceilings were drawn with software rendering. I simply ran out of time to translate the code to use the cell engine because the implementation I had caused texture tearing.

I had to write my own string.h ANSI C library because the one 3DO supplied with their compiler had bugs! string.h??? How can you screw that up!?!?! They did! I spent a day writing all of the functions I needed in ARM 6 assembly.

This game used Burgerlib 2. My first “C” version of Burgerlib because Burgerlib was originally written in 65816 for the SNES and the Apple IIgs. If you check out Burgerlib 5 (The current version, also on github), you’d notice that some code is still in use.

I hope that everyone who looks at this code, learns something from it, and I’d be happy to answer questions about the hell I went through to make this game. I only wished I had more time to actually polish this back in 1995 so instead of being the worst port of DOOM, it would have been the best one.

And one more thing…
The intellectual property of DOOM is the exclusive property of ZeniMax. No transfer of the intellectual property of DOOM or any transfer of the ownership of the sounds, art or other game assets are given nor implied. If anyone wishes to release a version of DOOM 3DO commercially, contact ZeniMax for a license.

The source code… Go for it.

Rebecca Ann Heineman

Olde Skuul

Seattle, WA