torsdag 22 september 2016

MAME: Saving old computers

When writing a MAME driver for an old computer it is more to it than one can think of.

You are seldom lucky enough to get full schematics or even access to real hardware. Sometimes all you get is a rom file from someone that worked on the system ages ago and some general idea. If you are lucky there are documents about the system on the internet somewhere like www.bitsavers.org. Sometimes you find a forum thread from someone who bought something on Ebay and posted some pictures asking people what kind of machine it was. The information mining and detective work is the first phase of the adventure. The less you find the more eager you'll get to find out what it was. At least that is how I am geared. :)

The next best thing after schematics are detailed pictures of the PCB:s involved which reveals the chips and how they are interconnected. However even with this at hand the PCB has components which hides the traces on one side and there might not be a picture of the bottom.


In this picture I have both bottom and top side of the PCB. The bottom part is mirrored so I can easily follow traces from top to bottom through the via holes without getting confused. Since I don't have the actual hardware at hand I can't use a volt meter to test which pins are connected, I need to see it on the image. I used Gimp to fill in the traces from the 74LS138 chip to be able to make an address map which is needed to write a MAME driver.

MAME also has a built in debugger which can be used to see where the rom code accesses things and then guess which of the chips it is, usually setup patterns from other drivers can be seen and verify the guess together with the visual trace on the PCB image.

It is actually great fun to figure out old designs from clues like this. In the end this specific work will be documented in the driver  and on my Candela page for others to find out.

fredag 16 september 2016

MAME: Esselte 100 and serial support

The Esselte 100 has a rudimentary serial port that is available on the multi faceted I/O port labeled "Printer" where also the different measurement experiments are attached. In order to use the serial port in the emulator it has to be started with an emulated null modem cable attached to something.

In this example we will run it against a Telnet terminal. In order to get out of the emulated world and into the real world we attach it to a bit banger device which in turn needs to be attached to a socket server. These parts will translate the emulation time serial communication into a data stream through the socket server to the telnet terminal.


The null modem has built in support for the bitbanger and does the translation between stream data and the selected baudrate. This is how you set up MAME to work this way:

First you can check what devices is supported by a certain driver. The driver for Esselte 100 is called e100 and the option to use is called -listdevices:


The interesting information here is "RS232 Port" because it is a slot device which we can explore further with the -listslots option:


Here we can see that the RS232 port device called 'rs232' supports null modem. From not so well known sources we also know that the null modem support a bitbanger device which in turn accepts a socket address as argument like this:


This will start MAME as we want it to, The connection between the PIA pins and the rs232 device is defined in the emulation driver for the Esselte 100 and not something we can change from the command line. Once MAME is started you can open Putty.exe or you favorite Telnet terminal and connect it to the socket server using 127.0.0.1 (or the IP address of the machine running MAME if you are using a Telnet terminal on another machine) and port 4321 ( can be change to any port ).

Skip through the alerts at the beginning af the MAME session and at his point you will see two windows, one with Esselte 100 and one with the Telnet terminal:


The Esselte 100 starts in 7 bit, 1 start bit, 2 stop bits and 300 baud so we need to set up the null modem to talk to us at this speed through the internal menu system of MAME. This is enabled by pressing Scroll Lock and then TAB. Enter the "Machine Configuration" menu and change the settings accordingly:

Press TAB to exit the menu and select the Esselte 100 window. In order to use the serial port easy there is a terminal mode built in which takes the baud rate as argument:


Press some keys and there should be text in your Telnet terminal, the emulation has escaped into the real world!! :)

Not much more works at this point but this is a generic method how to connect emulated system with each other or to the outside world, enjoy!

torsdag 1 september 2016

MAME: Esselte 100 and other Didact designs


Now you can try how using a computer at the beginning of the 1980ies felt like. At the time they all suggested that you had to learn programming or at least use the prompt and usually they had a BASIC interpreter built in. Esselte 100 had only 12Kb of ROM to start with which was later upgraded to 16Kb. 

Thanks to some dedicated people at elektronikforumet.com, a swedish forum for electronic enthusiasts, I got hold of schematics and ROM:s so I could start my Didact project. Esselte 100 is a Didact design and here is how you can run it in MAME on a 64 bit Windows 7 computer:

1) First download the MAME Didact beta package here: Didact beta MAME 177
2) Extract it somewhere
3) From the command shell type: .\didact64d.exe e100 -window

Just press enter on the informational messages that pops up and you should now have a prompt!


From here you can explore the wonders of BASIC.

To use the cassette you first need to enable the pop up menu system in MAME by pressing Scroll lock. It will toggle the menu system so you can turn it off later by pressing Scroll lock again. Once the pop up menu system is enabled you get the main menu up by pressing TAB

Select the File Manager and then the cassette option to open the file dialog



In the file dialog navigate into the demos folder and select a BASIC demo. Once a wav file is selected the "cassette" is loaded an ready to be used.

To load the demo from the cassette issue a 'LOAD' command at the Esselte 100 prompt. The Esselte 100 will ask you if you are ready and of course you are, press 'Y'. To start the loaded cassette press F2 and a counter will appear showing you where on the tape you are.

Under 'Tape Control' in the main menu there are additional actions that you can take in order to navigate the tape in case you have several saved assets at the same cassette or want to create a new one. More on the latter below.

While loading the cassette the Esselte 100 displays what it loads and when done it will clear the screen and sit at the prompt awaiting commands. Now you can look at the code by issuing a 'LIST' command and of course run it by issuing a 'RUN' command:


Saving your own BASIC program is similar but you need to prepare a cassette first. This is done by selecting [create] in the file dialog shown above, use file name of your choosing and append a .wav suffix, because MAME will actually generate a wav file.

In the 'Tape control' menu there is 'record' option and once you have pressed it a wav file is being written to file so quickly exit to the Esselte 100 prompt and issue a 'SAVE' command. Shortly, well 300 baud can take a while, you precious work has been saved! :) Press F2

If you write a nice Esselte 100 demo and want to share it, let me know and I can add it to the distribution. If you sit on original Esselte 100 cassettes, dump them to WAV files through the microphone input on your computer and then try to load them into the emulator as described. I am very interested to know how that works, it is not yet tested. You can also contact me and I can do it for you.

History of Didact

Didact Laromedelsproduktion was started in Linkoping in Sweden by Anders Andersson, Arne Kullbjer and Lars Bjorklund.  They constructed a series of microcomputers for educational purposes such as "Mikrodator 6802", Modulab, Esselte 100 and the  Candela computer for the Swedish schools to educate the students in assembly programming and BASIC for electro mechanical applications such as stepper motors, simple process control, buttons and LED:s. Didact designs were marketed by Esselte Studium to the Swedish schools. The Candela computer was designed to be the big breakthough and developed by Candela Data AB, "a Didact Company". The Candela system was based around a main unit that could run OS-9 or Flex and a terminal unit that had a propietary software including CDBASIC. The Candela system lost the battle of the swedish schools to the Compis computer by TeleNova which was based on CP/M initially.  Later both lost to IBM PC as we know. Candela Data continued to sell their system to the swedish industry without major successes despite great innovation and sprit.

onsdag 18 maj 2016

Emacs, tabs and helpers in general

I just had to dig up this after a discussion about TABs and coding standards. I prefer not to think about it, but most editors these days tries too much to be helpful including my old friend emacs. As soon as you are closing a paranthese, opening a comment or just tries to code in general it does the equivalent of that annoying spell checker.

What about all these helpers that nags at your attention, patience and defocuses yourself from the task you are trying to accomplish, who asked for these? It all started with the biggest annoyment there ever was, the Office Assistant Clippy!! Released around 1998


This flirting annoyment almost shortened my life by the lionpart when it arrived. To start with it was almost impossible to turn off and secondly the computers were already on their knees when it made the situation even worse and trying to be funny. My mother loved it though.

After that there have been a never ending stream of annoying helper additions for ignorant, illitterate and lazy people! I am probably all of that but I didn't ask for auto-spellers, tripple are-you-really-sure alerts and what triggered this rant: auto-indenters

Emacs was my friend up until it came with predefined language support where the indention style was predefined in some LISP file somewhere on your harddisk. Never in the same place and often your changes to it didn't take any effect because of god-knows-what!

In any case for the moment I found it for my Windows Emacs and also what to change: Edit the c:/Users//AppData/Roaming/.emacs and read here about the changes you want to do:

https://www.emacswiki.org/emacs/IndentingC

It works now but soon I have forgot about it until next time I have to turn it off, change it or even turn it on. We spend too much time beeing defocused from the task we are trying to accompplish!

Another example is the auto-speller that corrects whatever I write to something readable. I only have to hit keys close to the ones that resembles a word and it even marks up the errors in grammar. Geehh I don't know how kids in the future will be able to write with a pen on a paper. Will they?



MAME serial support Part II

I have previously submitted a driver for the Zilog SCC, Serial Communication Controller, to MAME, improving it while working on different board drivers needing it. While one would want everything to be emulated correctly from start it crucial to find some legacy code to test the feature at hand. Unless you do the effort is not useful anyway.

Usually a board initiates the SCC and start sending characters through it to an unknown device at the other end. The device on the other end will eventually send something back and the firmware will respond to it. Quite simple ehh!?

The way this is done can differ a lot though and if a feature used is not emulated or previously tested it is important that the board writer get useful messages using the logerror(). I usually start with that, creating logerrors for everything that doesn't work, so when a new software is tested there are printouts saying that this feature is not implemented. Then it is Time to call Saul.

[ The logerrors are seen in the debugger log window. The debugger is enabled by the -debug command line switch from where you start the board driver with F5, but first you want to open the log window by Ctl-L. ]

When writing the board driver for the MVME-147 I had problems getting the keyboard on the terminal to produce input. The funny thing was that the output worked just fine. Hmmm... I had to dive into the core code to understand how this was possible. The core feature that allows us to connect a serial device to a terminal as previously explored is mainly kept in src/emu/diserial.cpp

I had recently added support for SCC:s internal baud rate generator by adding a timer. It worked in the board driver for hk68v10 board but for MVME147 it failed. I pretty soon figured out that the serial timing was not working since I sometimes got a character through but sometimes the system got it wrong by just a bit or so.

I had to investigate it of course and I found several weaknesses of my first implementation in relation to how diserial works and can do for you. Here is my post on the MAMEdev forum summarizing it like this:

"I found the bugs finally, it was due to that it is not possible to use diserial the way I did with local baudrate timer in the SCC device. I got it nearly to work one way as can be seen above but when sending keypresses the other way there was problems. The SCC device wasn't producing exactly the right baud rate but nearly enough to being able to send characters from the board to the terminal, but in the opposite direction there was not start bit detection and there was no mid bit alignment in the SCC device. Even after adding that it turned out that I didn't get the final transmitt_complete because it also had no stop bit detection... So I relized I was reimplementing diserial in the SCC device and after I relized that it took me just 20 minutes to implement the baudrate timer using the diserial setrate() functions. So that part is now rock solid compared to how it was and the MVME-147 driver was submitted a few days ago with a working 147-Bug> terminal."
So to not reinvent the wheel you need to recognize a wheel...

måndag 9 maj 2016

Serial ports in MAME part I

Serial port emulation is a much more intriguing subject than you probably think. I am writing on a number of pages exploring different aspects of the support for serial ports in MAME. The first one is describing what a typical addition of a serial port to a board driver looks like and you can check it out here: serial-port-in-mame.html

Adding the serial port is the easy part, as a board writer you often just find a board that has a similar feature to what your board has and copy the apropriate lines to your driver. However, unless you know how it works the driver will probably not work properly or to the full extent.

In the other end of the RS232 cable there is another device, normally a terminal or a printer but it can be anything. MAME has some default devices that behaves like that class of devices normally behaves.

A MAME top level board driver describes a system rather than a board so the name board driver is somewhat misleading. In MAME you start the board driver and give it configuration options to activate one of many preconfigured devices compiled into MAME that is pre configured to work with that particular driver. For instance there can be a default serial terminal device configured, in which case a terminal window just pops up and starts working without any extra parameters:

./mame fccpu1 -window


There are options that I have not yet explored to connect MAME to a real terminal, this has another set of host related problems that I intend to look at later.


torsdag 14 april 2016

VHS preservation and video editing

I have just saved a VHS tape from 1982 filmed at a rehearsal with a band I played in as a teenager. Some time ago I saved my mothers old DVD/VHS recorder, a Panasonic NV-VHD1, which for some reason was going to the recycling, but I figured it will have its use with me instead.


 Second stage was to get a video grabber and I borrowed one with USB from my son that has used it to capture retro game play, a Plexgear Moviesaver 220 VHS
After installing the Plexgear Moviesaver driver and application for Windows 7 and connecting all the cables it was no problem at all to insert the tape in the VHS cassette player and press play and then record in the application. It worked as expected and stored the VHS content as a MPEG-2 audio/video file at the same time as displaying it in the app so it was really easy to manage.

I've had preferred to do it on Linux but I found no luck for this USB device after some Googling around on the subject and I have stopped trying Linux when it lacks support and started to do the right things rather the things right always.

When reviewing the tapes I realized that I wanted to share some of it, but 30 minutes of rehearsal was too much for anyone to watch these days so I picked the shortest song recorded, it was 2 minutes roughly, perfect for the restless era of internet!

But even the two minutes were filled with recording errors such as out of focus passages and pointless pans. Especially when zooming in at the wrong guy during both solos in the song, how hard was it really?! :-p

I had to do something about it and downloaded Blender, a blender for digital content, and in fact the VHS content was digitized, so what was I waiting for? Said and done, I downloaded Blender on both my Windows-7 machine and my Ubuntu 14.04 Linux machine and they worked right off the bat, great out of the box experience!

Except for that I didn't have a clue how to edit video that was.... and Blender just scared the sh*t out of me when I first started it up with its about 2 zillions menus and options. The first I saw was a 3D editor... So I looked around at Youtube and found a couple of guys who thought they knew more than average about Blender.

After screening out the web cam generation, speed talkers and guys with voices I couldn't stand I finally  selected a guy in the thirties that had a long series of Blender video editor instructional videos, like 25-30 of 5 minutes each. I highly recommend Mikeycal Meyers for people who wants to know how to edit video with Blender



I spent some time looking at the fiorst 10-15 videos and then I said to myself that this was easy and dived in. After about 5 minutes I was totally lost, I remembered what I could do with Blender but hardly anything about how! So restart, I rigged my laptop with the instructable videos on the right of my big(er) secondary computer screen and fired up Blender there. Much better! After some fumbling I got the hang of it and after the initial 3-4 videos I knew enough to create my 2 minutes video:
This is a very basic example of what you can do with Blender, just cutting some tracks and arrange them in an arbitrary order. Blender let me copy video fragments from other parts of the VHS recording and put them on top of the poorly shot video during the song. The original video is never harmed! You simply press a button when you want produce the video. Then you are a producer!

If I have had a better memory or more time I would have made a rocket ship with what was tutored in the rest of the videos but that is for another day and another movie, this is good enough and a lot of fun! I am playing the drums btw!