Announcing Cockatrice III

Well I was shuffling files back and forth into Shoebill, and with the advent of Ethernet support, I decided I wanted to build an AppleTalk network.  This endeavor seems to have taken a life of it’s own.

So, the first thing I did was tear into minivmac, as I figured it would be the easiest to modify, as ‘mini’ is in it’s name.  But it’s more geared to LocalTalk.  From it’s readme:

It does this by converting the LocalTalk packets between SDLC frames in the virtual machine to LocalTalk Over Ethernet (LTOE) packets.  These LTOE packets will be sent out the host machines Ethernet interface and will reach any other machine on the LAN.  LTOE packets are not routable and not recognized by EtherTalk devices.

Which is pretty creative, but I want to talk to A/UX, Windows NT and Cisco routers.  So this isn’t going to work out for me.

The next other ‘big’ names in Macintosh emulation are Basilisk II and SheepShaver.  Both of which are from Christian Bauer which is a sizable download (or so I thought) and has a very confusing release versions for Windows. So I went ahead and tried BasiliskII, which only does some native networking via a TUN/TAP & bridge solution (which is really popular solution for plenty of UNIX based stuff), which personally I don’t really care for.  The Windows version does support SLiRP, but for some strange and annoying reason it always crashes when I try to download anything big.  As a matter of fact, the Windows version crashes, a lot!

While digging around for various builds of Basilisk II, I found the defunct sourceforge page, which is thankfully still up.  And there I found the 0.8 and 0.9 release source code, which weighs in at a tiny 350kb in size.  This is something I could probably dive into.  So I went ahead and tried to build it on a Debian 7 x86 VM.  And much to my surprise, after altering configure to accept GCC 4.7, and forcing it to turn X11 on (I don’t know why it kept failing to detect it), I was able to build a binary in no time.  Even better, it worked!

So the first few goals were simple, I wanted to take 0.8 and remove it’s dependency on X11,and make it use SDL 1.2.  Why not SDL 2.0?  Well 2.0 is more about 3d space, and even to render a flat framebuffer it uses streaming textures.  Which is too heavy for me, so I’m sticking with 1.2.  I took a bunch of code from SDLQuake, and after a while of bashing it around, I was able to open a window, and capture some ouput from the framebuffer.  With even more bashing around I got it to work correctly.  I did make some small tweaks though, it only supports 8bit depth.  But I’m interested in networking, so 256 colours is fine by me.  Now that i could see what I was doing, I was able to then re-compile on OS X, and I was greeted with the Mac Boot screen.  The harder part was Windows, as the system code written by Lauri Pesonen who did an excellent job of porting BasiliskII to Windows, but to say their code took 100% advantage of the Win32 API would be an understatement.. And I wanted something more pure to being SDL so I really couldn’t use much of that code.  And what code I could find it was for far later versions.  However with enough pushing I did finally get BasiliskII to boot up on Windows.  I was once more again bitten by the fact that open on Windows defaults to being in ASCII mode.

The next thing to add was SDL input for the keyboard and mouse.  And at this point googling around for an example of an input loop for SDL that is appropriate for an emulator I stumbled uppon the fact that there already was a SDL support built into the more current version of Basilisk II.  But for some strange reason I kept going ahead, and incorporated some of the code into my 0.8 branch.  And then I could finally send some keystrokes, move the mouse, and click on things!  Things were looking up!

While looking at the SDL code, I did see they also have audio support, so I went ahead and borrowed the skeleton framework from there, although the initialization didn’t work at all as BasiliskII had drifted in how it hooked into the native sound support.  So I once more again turned to SDLQuake, and I was able to initialize sound, and Even get QuickTime to play the old Quadra quicktime video, which was the first QuickTime thing I’d ever seen, back when they were still making Quadras.

So now with video and sound in place, it was finally time to tackle the networking.  At first this seemed quite easy to do, and using SIMH for inspiration I was able to quickly replace the tun/tap code with some pcap code to open the interface, send packets, and receive packets.  One more again I started on Linux, made it build on OS X, although my MacBook air doesn’t have anything I can really inject packets into so I don’t know if it actually works.  The bigger test for me was on Windows with a GNS3 network, and with a few more minor changes I was happily sending AppleTalk to both Shoebill and Windows NT.

The next thing I wanted to tackle was SLiRP support.  Ironically to bring SLiRP to Shoebill I used the SLiRP from the github of Basilisk II.  At this point I figured this would be very simple, and I could wrap up later that day.  It ended up taking me three days.  Once more again my build would crash all the time, just like the later Basilisk II builds.  Using Internet Explorer 4.0.1 would seemingly crash the whole system within seconds with faults in SLiRP’s slirp_select_fill, and slirp_select_poll functions.  Now if you don’t call these functions SLiRP doesn’t process it’s TCP state and you end up with barely functioning UDP to only SLiRP which isn’t great beyond DHCP and DNS.  First I tried semaphores which only made things worse as the nature of Basilisk II’s threaded nature just made the requests stack up deadlocking within seconds.  I tried a mutex, timed mutexes and various other locking methods insdide of SLiRP and Basilisk II to no end.  Netscape would kind of work, but IE would crash the whole thing out after a few pages. Then a better solution hit me as I was playing with the system clock on the Windows build.  There is a 60Hz timer that calls a 1Hz timer once every 60 ticks.  What if I had the clock drive SLiRP?  And to my amazement not only did that work, but it worked great until I hit another problem that I had with Shoebill (that needs to be fixed now that I found away around it here).  There is a static buffer that passes data between SLiRP’s callback when it is going to send a packet to BasiliskII and when Basilisk II then feeds the packet to MacOS.  With enough traffic it will overwrite part of itself as they are on two different threads.  Once more again I tried semaphores, which of course is the wrong tool here as if something is stacking waiting for it to unstack is just crazy, and more mutexes.  The mutexes kind of worked but performance was horrible, as in 1992 dialup speed horrible.  And I didn’t want to simulate a 1992 internet experience 100%

So the obvious solution as a queue.  I took a simple queue implementation, added the ability to peek, changed it to accept a packet structure and I was set.  Now I only needed a mutex when I queued items, and dequeued them.  But I could hold 100 packets easily.

So with all that in place I can finally download files greater than 10MB, and even with Internet Explorer!

Download

124MB in 8 minutes!

So the next was to make Pcap dynamically loaded, which for C++ is a bit of fun with __cdecl, GetProcAddress and all that fun.  But I had it working after a bit so now if the user doesn’t have WinPcap installed they don’t get an error message, and I don’t have to maintain two builds.  Nobody likes doing that kind of stuff.  Ever.

Multitasking.. Kind of.

Multitasking.. Kind of.

There is still plenty of things broken afterall I’m using an ancient version of Basilisk to base this off of. I’ve also removed a bunch of features as I wanted to make this more of a ‘core’ product with again a focus on networking.

Will this interest the majority of people? Probably not.  But for anyone who wants to actually download a file this may be somewhat useful.

Where to go from here?

Well there is still a lot of OS specific stuff in the code that I want to convert to SDL.  I’d like to build from a 100% more generic code tree rather than having private files here and there.  The CPU optimization programs that re-read GCC’s assembly output don’t do anything.  I want to try it through an older version of GCC and see if there is any difference in speed.  I also recently received the source code to vc5opti.cpp and I’d like to try that to see if it speeds up the Windows Visual C++ based build.  Long term I’d love to patch in the UAE CPU code from the newer versions that have a far more solid 68030/68881 and 68040 emulation.  The price of standing on so many tall shoulders is that when I fall off I don’t know if the CPU exceptions I see are faults in the CPU emulation, Basilisk II or just plain crashes in MacOS which was certainly not the most stablest thing once you mixed in multimedia and networking.  It was par with Windows 3.1, which honestly both of them were ‘saved’ with help from the older generation, ala BSD Unix for MacOS, and the VMS team for Windows.

So after all this I’m ready to release some binaries, and code.  Although the last thing I wanted to do is add more confusion by calling this Basillisk II v0.8.SOMETHING … A quick google search on Basilisk gave me this:

As for some reason I actually never did look up what a Basilisk was.  So seeing that this project is basically the same thing I chose Cockatrice.

The Cockatrice III source forge page is here, Windows binaries, Mac OS X binaries, and source code here.

There are plenty of bugs, and plenty of things not working, but it works well enough to do things, and that is a credit to everyone who worked on Basilisk II before me.

Shoebill now has working Ethernet support!

Great news!  The excellent A/UX capable emulator Shoebill, now has working Ethernet support!  The sad news is that it only supports the TUN/TAP interface.  So Windows users are kind of left out in the fun.

Shoebill + Ethernet

Shoebill + Ethernet

Except, I’ve been here before with SIMH ages ago.  So I dusted off my source code, and injected it into Shoebill.  The first issue I had was that SLiRP was rejecting all the inputted frames, because of invalid frame length.  Even more weird is that ARP worked, and I could see the 10.0.2.2 and 10.0.2.3 virtual IP’s but TCP and UDP outbound wouldn’t work at all.

It took me longer than it should have but although this code worked great with GCC 2.7 and 3.0, 4.x breaks it.  And it’s the same reason why Shoebill originally didn’t work on Win32, the blasted packed structures!  So adding the ‘-mno-ms-bitfields’ flag to GCC is all it took, and now I could ping 10.0.2.2 for about 5-7 pings until SLiRP would crash.  I tried all kinds of stuff trying to see if there was an issue with SLiRP, but I should have payed closer attention to the debugger, with all those threads flying around.  It turns out Shoebill was trying to read & write a the same time, which caused SLiRP to crash as it is not re-entrant.  I tried to place mutex’s on every SLiRP call but that ended up having SLiRP not process any packets.  Very strange.  I then reduced it to where I read the frame out of SLiRP and pass it to Shoebill, and where Shoebill write’s a frame out the SLiRP.  And much to my amazement I can run ‘worms’ just fine!

So after a minute of worming and pinging I called it ‘good enough’ and rebuilt a production binary, and packaged up my source code.

For anyone who want’s to play, my Win32 EXE is here, and the source code I am using is here.

NetBSD 1.2 for the MicroVAX II package…

Well looking around on my sourceforge page, it hit me that I never did do a NetBSD 1.2 MicroVAX II package, so I thought I’d slap one together.  I basically just followed my install notes, and added in some stuff that I’d built earlier.

So for those who care, here you go!

From the package’s readme:

Welcome to this minimal version of NetBSD 1.2 for the MicroVAX II.

Getting started
:::::::::::::::

just fire up the emulator like this:

vax.exe run.ini

—–8<—–8<—–8<—–8<—–8<—–8<

C:\netbsd1.2\test>vax.exe run.ini

VAX simulator V3.8-1
run.ini> set idle OLDVMS
Non-existent device
TS: creating new file
Loading boot code from ka655x.bin

?[c
KA655-B V5.3, VMB 2.7
Performing normal system tests.
40..39..38..37..36..35..34..33..32..31..30..29..28..27..26..25..
24..23..22..21..20..19..18..17..16..15..14..13..12..11..10..09..
08..07..06..05..04..03..
Tests completed.
>>>
—–8<—–8<—–8<—–8<—–8<—–8<

You’ll be booted up to the boot rom. next we have to boot from the
hard disk. NetBSD’s bootblocks were very fragile back then so
it won’t autoboot. I never did tear into it to see why it won’t boot
so you’ll have to do it the old fasioned way.
>>>b/3 dua0
(BOOT/R5:3 DUA0

2..
-DUA0
1..0..
howto 0x3, bdev 0x11, booting…done. (11108+33996)

Nboot
:ra(0,0)netbsd
—–8<—–8<—–8<—–8<—–8<—–8<

Once you’ve booted the kernel, it’ll probe out the hardware, then
it’ll ask where the root disk is (ra0a).

—–8<—–8<—–8<—–8<—–8<—–8<
zs0: timeout waiting for TS_SSR
tmscp0 at uba0 csr 174500 vec 760, ipl 15
tms0 at tmscp0 slave 0
qe0 at uba0 csr 174440 vec 754 ipl 15
qe0: delqa, hardware address 08:00:2b:aa:bb:cc
dz0 at uba0 csr 160100 vec 304 ipl 15
root device?
—–8<—–8<—–8<—–8<—–8<—–8<

Armed with this information you can simply hit enter as it’ll want
to drop to single user mode, then hit contrl+d and it’ll resume booting
into multiuser mode.

—–8<—–8<—–8<—–8<—–8<—–8<
root device? ra0a
?Enter pathname of shell or RETURN for sh:
#
—–8<—–8<—–8<—–8<—–8<—–8<
remember it’s enter then control+d

—–8<—–8<—–8<—–8<—–8<—–8<
#^D setting tty flags
starting network
add host amnesiac.my.domain: gateway localhost
add net default: gateway 10.0.2.2
starting rpc daemons: portmap.
starting system logger, time daemon.
checking for core dump…
savecore: no core dump
checking quotas: done.
building databases…
clearing /tmp
standard daemons: update cron.
starting network daemons: routed printer inetd.
creating runtime link editor directory cache.
starting local daemons:.
Tue May 5 08:29:22 PDT 1998
May 5 08:29:22 amnesiac init: kernel security level changed from 0 to 1

NetBSD/vax (amnesiac.my.domain) (console)

login:
—–8<—–8<—–8<—–8<—–8<—–8<
And there we go, NetBSD is all booted. The network is configured, you
may wish to change the /etc/resolv.conf if you so wish.
USING NETBSD
::::::::::::

Once the system is booted up into multiuser mode, TCP/IP is enabled and
you can now telnet into your system, by connecting to the localhost on
port 42323.

telnet localhost 42323

will connect you, and you’ll get the login prompt:

—–8<—–8<—–8<—–8<—–8<—–8<
NetBSD/vax (amnesiac.my.domain) (ttyp0)

login:
—–8<—–8<—–8<—–8<—–8<—–8<

There is no root password, so you can just login as root, and away you
go. I prefer to telnet in so I get a working terminal as the console
doesn’t do any VT100 emulation, its more of a dumb TTY. Outside of the
default programs in NetBSD the following programs have been installed
into the image:
* bash-2.0
* dungeon-2.5.6
* ircii-4.4
* lynx-2.8.2
* GNUmake-3.75
* pine-3.87
* screen-3.7.1
* unzip552

This should at least make using the system somewhat tollerable.

FAQ
:::
Q:When I hit backspace I get ^H ‘s!!!
A:stty erase <backspace>

In unix they used keyboards with delete keys instead of backspaces… Oh the horrors.
SHUTTING DOWN
:::::::::::::

This should be simple, login as root and just issue the following command:

reboot

And you’ll get halted to the SIMH prompt from there you can just quit.

NetBSD 1.2 MicroVAX II

 

 

SIMH 3.8-0 with slirp

Ive been testing this build now for over two hours with Quasijarus & the microvax… All seems well.

http://sourceforge.net/projects/simh/files/Unofficial%20Patches/3.8.1/

The new build of SIMH with SLiRP adds some performance improvements, along with the older more compatable idle code. I’ve included the source with this build so I don’t lose it again… I can’t say just how difficult it was to piece this together again from my notes, and sadly it should have been way easier. The vax/vax780/pdp11/pdp10 are already prebuilt for windows users, and I built them with MinGW… YMMV as they say.

But if you are using one of my prior BSD packages (the 4.2 or the 4.3 RENO) you’ll want to replace the vax.exe/vax780.exe’s with these ones, and alter the config so that they both have

set cpu idle=FIX

that way it’ll run faster, and take up far less cpu when idle… Right now my Quasijarus is using 5% of my laptop idling with 1 connected user.