TSR-80 micro computer MC-10 emulator.

User projects written in or related to FreeBASIC.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

My plan is to write an emulator of my first computer (32 years ago) the MC-10 from RadioShack / Tandy.

Wikipedia: TRS-80 MC-10

If anyone wants to see how to do that
no problem follow this short "project".

Part 1: Resources.

Inside the Radio Shack MC-10: http://slowcomputing.org/ssouth/mc10/
The expansions port: http://www.vavasour.ca/cfdm/v001n003/page154.htm
The tape fileformat: http://www.cs.unc.edu/~yakowenk/coco/te ... ormat.html
The MC-10 optional hardware: http://oldcomputers.net/mc-10.html
Software and Books for the MC-10: http://mymc10.tripod.com/software.htm
Basic Game Programs: http://faculty.cbu.ca/jgerrie/Home/jgames.html
...

The curent result:
mc10.bi (right click save as)
mc10.bas (right click save as)
[F2] = save BASIC
[F3] = load BASIC
Last edited by D.J.Peters on Oct 03, 2017 4:34, edited 8 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

Part 2: The TSR-80 MC-10 in more details.

TSR-80 MC-10 service manual: ServiceManual.pdf

Motorola MC6803 MCU datasheet: mc6803.pdf

Motorola MC6847 VDG datasheet: mc6847.pdf

Circuit diagram (click to enlarge)
Image

The tiny plastic keypad. (click to enlarge)
Image
Last edited by D.J.Peters on Oct 03, 2017 4:34, edited 13 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

Part 3: The Motorola MC6803 CPU.

to do list:
Registers
ALU
Multiplexed Address- and Data bus
memory map (RAM/ROM)
addressing modes
Opcodes
CPU
IO Ports
Keypad
MC6874 VDG
Cassette/Tape
Sound
Last edited by D.J.Peters on Oct 18, 2014 7:56, edited 15 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

Part 4: The Motorola MC6847 Video Display Gernerator and the keypad.
Last edited by D.J.Peters on Oct 06, 2014 17:07, edited 4 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

Part 5: Disassembler, Macroassembler and BASIC.
Last edited by D.J.Peters on Oct 06, 2014 16:29, edited 4 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

Part 6: Cycle correct emulation and audio.
Last edited by D.J.Peters on Oct 06, 2014 16:28, edited 2 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

Part 7: All together, does it works ?
Last edited by D.J.Peters on Oct 06, 2014 17:58, edited 1 time in total.
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by vdecampo »

Never owned an MC-10. I had a Model II/III/IV, CoCo2/3 and Tandy 1000/2000 though. :)

-Vince
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

A preview of my emulated MC6847 Video Generator.

Looks like in the 80's lowercase ASCII was luxus. :-)

Joshy
Image
Last edited by D.J.Peters on Oct 03, 2017 4:32, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

After 40,000 debug steps ?!?
(source code see above)

Joshy
Image
Last edited by D.J.Peters on Oct 03, 2017 4:32, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

I was thinking the keypad isn't a big deal but I don't get the right keys.
Looks like the BASIC OS scans all lines of the key matrix 3-7 times per cursor flashing.

He are the diagram if some of you have an idea.
The key board matrix. (click to enlarge)
Image
I can poke some "random" values but i get only this three keys 'D' '@' and 'T'.

Joshy
Last edited by D.J.Peters on Oct 03, 2017 4:35, edited 2 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

I think (but I don't know it) the pins 7-0 of Port 1 are defined as inputs.
So if you press on the real device a key a line of the matrix goes low (from the +5V above)

Note: you can see the +5V line 3 isn't connected.

As an example from my point of view the [ENTER] key in the matrix would be "normaly"
bit 5 = 16 on Port 1 pin 6

&B00010000 and as reverse "low pegel"
&B11101111 but my emulated CPU doesn't detect the ENTER key.

Code: Select all

pMem->Port1[6] and = not (1 shl 3)
Any idea what i'm doing / thinking wrong ?

You can try it self with the latest source code if you like.

Sendkey() calls KeyUp() and KeyDown() and inside of KeyUp() and KeyDown() you can set or reset the 7 lines of Port 1.

Joshy

Code: Select all

...
...
...
sub MC10.KeyDown(byval key as ubyte)
  dim as ubyte b,m
  ' A-Z
  if (key > 64 and key < 91) then
    b=key mod 8:m=(key-64)\8:m=1 shl m
    WindowTitle "KeyDown " & key & " " & bin(b,8) & " " & bin(m,8)
    pMEM->Port1[b] and=not m
  elseif key=13 then
    pMEM->Port1[6] and=not 16
  end if

end sub

sub MC10.KeyUp(byval key as ubyte)
  dim as ubyte b,m
  ' A-Z
  if (key > 64 and key < 91) then
    b=key mod 8:m=(key-64)\8:m=1 shl m
    pMEM->Port1[b] or= m
  elseif key=13 then
    pMEM->Port1[6] or= 16
  end if
end sub

sub MC10.SendKey(byval key as ubyte)
  static as ubyte KeyTab(255)
  static as ubyte LastKey=0
  if LastKey<>Key then
    if KeyTab(LastKey) then
      KeyTab(LastKey)=0
      KeyUp(LastKey)
    end if
    
    if Key then
      if KeyTab(Key)=0 then
        KeyTab(Key)=1
        KeyDown(key)
      end if
    end if
    LastKey=Key
  end if
end sub


function MC10.Tick as integer
  'dprint(this)
  return pCPU->Tick()
end function

'
' main
'
dim as MC10 computer
dim as integer counter,key
while key<>27
  computer.Tick
  counter+=1
  if (counter mod 3000)=0 then  
    key=Asc(Ucase(Inkey()))
    Computer.SendKey(key)
    if key=0 then sleep 10
  end if
wend
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Re: TSR-80 micro computer MC-10 emulator.

Post by oog »

D.J.Peters wrote:I think (but I don't know it) the pins 7-0 of Port 1 are defined as inputs.
Hi Joshy,

regarding to the schematic, U14 has input and output pins. So the direction of Port 1 (KR0 - KR7) must be outputs to make the keyboard work.

The inputs of U14 are pulled to hi level with the resistor array R20, when no key is pressed. The outputs of U14 are inverted, so - if no key is pressed - the output signals D0 - D5 are low.

Configure Port D0/A0 - D7/A7 of U1 for input to read the keyboard.
Port P21 has also to be configured for input, but the signal comes directly from the keyboard shift keys and are not inverted. So a low level indicates a pressed key.

To scan the matrix, configure P10 to P17 for output and set ond bit to low to select the keyboard matrix.

For example of the enter key:
P16 mus be low, the other P1x must be high.

If you press enter, I4 of U14 goes low and the inverted output O4 goes high.
Now you read 0bxx001000 from Port D0/A0 - D7/A7
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: TSR-80 micro computer MC-10 emulator.

Post by D.J.Peters »

Hello OOG and thank you for the description.

I have disassembled the RESET Vector of the MC6803 CPU.
The first 4 CPU instructions defines the port direction of Port 1 & 2.

All pins of Port 1 are defined as input and the Port 1 Data Direction Register (DDR) at RAM_00
is never touched again by the running system. (so far i know ATM)
Only one pin of Port 2 are defined as input via data direction register at RAM_01 .

From the MC6803 data sheet a '1' means a port pin is input and a '0' as output ?

Code: Select all

3286   F72E 86 FF      LBL_F72E         LDAA    #$FF ; The RESET vector FFF2 points to here. 
3287   F730 97 00                       STAA    RAM_00      ; DDR Port1 11111111 all lines as input
3288   F732 86 01                       LDAA    #$01
3289   F734 97 01                       STAA    RAM_01      ; DDR Port2 00000001 line 0 as input
But you are right U14 put's out the 6 inputs inverted on D5-D0.

I'm more confused as before time to go in the pub
because it's friday evening here. ;-)

Joshy
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Re: TSR-80 micro computer MC-10 emulator.

Post by oog »

Really confusing.
I searched for the MC14503B data sheet and it says it's a "Hex Non-Inverting 3-State Buffer". So the outputs are not inverted, but the symbol in the schematic shows inverted outputs (signed by the line above the "O").

So maybe the schematic is not perfect.

There's another issue with the schematic. I would expect to use a diode for each of the KR0 - KR7 signals. Without diodes it's possible to have a short circuit. For example, if Keyboard Row 0 is selected (KR0 = Low, KR1 - KR7 = high) and you press key "8" and "9" together, then you shorten the high and low outputs.
This could damage port P1 of the MC6803. Nobody would design it in that way (if the keyboard has no internal resistors which we don't see in the schematic).

Edit:
Found another schematic of the trs80 keyboard that makes more sense:

http://incolor.inetnebr.com/bill_r/trs8 ... rt5of5.GIF

The LS05 hex inverters with open collector outputs does not have a short circuit problem.
In that schematic the keyboard is driven by the lower address lines. So you just have to read address hex xx01, xx02, xx04, xx08 etc to scan the keyboard. Pretty good money saving circuit.

Edit 2:
This one has a Z80 CPU, seems to be something different. I'm more confused now.
Post Reply