# SBC3 Emulator

It's quite a time consuming programming cycle for both the monitor and NetBSD, for different raesons in each case:
- for the monitor, you build then have to burn an eprom which takes several minutes
- for NetBSD, you have to load a 4MB s-record file over serial - again, that's several minutes

It would therefore be very beneficial to have an emulator for the board that was good enough for most testing. Obviously, the final proof of the pie still has to be running on the board but with a good enough emulator, development time could be speeded up hugely.

## Step up, Mame
Mame already has all the components we need to emulate an SBC-3, so it's simply a matter of creating a machine definition.

## Using the emulator

### ROM image
the emulator runs in two different ways:
- Boot into the ROM monitor
- Load a program (e.g. netbsd) into RAM and run it

If you wish to run the monitor, you'll need to provide a copy of it. You need to create a folder in the mame tree and put the file in there. Here's what I did:
```
bob@bsddev2:~/Mame-SBC/mame$ mkdir -p roms/sbc3
bob@bsddev2:~/Mame-SBC/mame$ cd roms/sbc3
bob@bsddev2:~/Mame-SBC/mame/roms/sbc3$ wget https://mega-micros.co.uk/system_roms/v2.05b118_68681/system_rom_v2.05b118_27c322.bin
bob@bsddev2:~/Mame-SBC/mame/roms/sbc3$ ln -s system_rom_v2.05b118_27c322.bin ./sbc3.bin
```
I use a symbolic link so that's I can have multiple monitors and use the symlink to set a default.

**Starting the emulator with the monitor**
```
$ ./sbc3-term.sh -hard card.hd -quik netbsd
```

**Starting the Emulator with a NetBSD image**
```
$ ./sbc3-term.sh -hard card.hd -quik netbsd
```

### Environment variables
Some aspects of the emulator can be overwritten using environment variables. See the table below for more details:
| Name | Function | Default |
| :--- | :---     | ---     |
| BAUD | Sets the baud rate for the console port. | 230400 |
| JUMPERS | Change which jumpers (connected to IP0-5 on the duart) a present. Specify a list of numbers, from 0 to 5 inclusive. | 0 1 2 |
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9