PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

A video of the startup.

Still a lot of checks and the BASIC will be translated to Z80.

Next read keyboard for input

zx_if1
Drutt
Posts: 48
Joined: Fri Jul 16, 2021 8:53 pm
Location: Peru
Contact:

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by zx_if1 »

ok ok...
that's amazing!

hi dr. beep
I can't wait to see it finished to try it and write something about it as I did before
with the SP2ZX81 or the VIC20 emulator too and publish it in EL Trastero!
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

zx_if1 wrote: Mon Aug 28, 2023 7:31 am ok ok...
that's amazing!

hi dr. beep
I can't wait to see it finished to try it and write something about it as I did before
with the SP2ZX81 or the VIC20 emulator too and publish it in EL Trastero!
Your review about SP-2-ZX81 gave me the solution to add SAVE.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

Having troubles to get keyboardinput working.
I think a key has reset before I read it again.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

4 opcodes still had an error, now first keyboard input is read, althogh the translating is still off.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

Unlike the ZX Spectrum or the ZX81 you need to read the keyboard after setting a register with a port value.
I had keyboard reading at the intrupt but when the intrupt occurs after reading keyboardresult the key is read wrong.

I need to add a check when writing to memory is done to zeropage address 2 to activate keyboardscan.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

The first keyboard input is working. Need to check a few keys but almost ready.

Image
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

The line check routine alters the SP so I needed to add a DI somewhere and a EI also to keep stack unchanged while
checking the line. I did a dirty trick that seems to work.

My emulation of PUSHING and PULLING a single register was not right emulated.

Next thing is a check on registervalues when register are STORED in memory.
I already added a check when LOADING, but storing also checks on values.

The processor is really different from a Z80.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

the MC10 uses a same trick with the SP as is done in rainbowgames, however….
The Z80 does dec sp and then writes a value where the mc10 first writes and then does a dec sp.

this goes wrong when input is checked with the SP-trick.

i tried a solution but in the end thought that an alteration in the SP will work.
I still need to test it…
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

Yesterday I had the idea for the SP-fix.

15 minutes after I had the idea I was passed on the highway by a german car with licenseplate SP-I 1111
This confirmed my idea, why? I needed to adjust the Stackpointer, SP on the Z80, the car came from SPeyer.
Same letters

My game SHOGUN uses a capital i as the number 1 for the value 1 for the shogun (Z=2 btw).
The I indicated a "1".
I needed to adjust the SP with 1.

And then 4x the confirmation that 1 is the right value.

So I altered the SP a bit and now the emulator makes a few more steps.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

The emulator executed it first command CLS gave a clearscreen.

I still have other bugs to solve.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

I had the idle hope that loading and storing registers would not need the carry-flag status.
I already needed to add a test on the zeroflag, but the carry flag is also needed to keep.

Since the test of zero/not zeo effects the carryflag I needed to split an opcode in 2 steps.
Test if carry is set and set again after zerotest or inly do zerotest.

Extra check will slow down the emulation
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

I have a simple test
I enter this program

1CLS

and then LIST the program.

First I did not even get a list, now I get linenumber and wrong code.

Step by step getting it running
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

XOR, OR and AND do NOT reset C!

Again change in the code
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

The TRS80 MC10 has an overflow flag which the Z80 has not.
I need to emulate that flag. In the ROM it is used on 3 places so I will only change the 3 opcodes before the flag is tested.
This is not perfect but it will be noted in the known issues. If a game would not work the test of the overflow flag is done.
catmeows
Manic Miner
Posts: 721
Joined: Tue May 28, 2019 12:02 pm
Location: Prague

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by catmeows »

I think Z80 has overfow flag and both 6800 and Z80 V flags behave in same way, indicating overflow of signed values.
I'm suspecting you are using alternate F to track 6800 flags, are you?
Proud owner of Didaktik M
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

A full day trying to find the next bug.
Some opcodes used a PUSH / POP but the program used the stack to scan input so the emulation corrupted the input.
User avatar
Quazar
Drutt
Posts: 31
Joined: Tue Jun 16, 2020 2:28 pm
Contact:

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Quazar »

Dr beep wrote: Fri Aug 25, 2023 9:17 pm i don’t have the sources anymore.
it was on a computer that is long gone.
I can help here. I tried to send a PM, but it sits in Outbox instead of sending - maybe your inbox is full?
Quazar - Developing for the SAM Coupé for 30+ Years!
Hardware, Software, 'SAM Revival' magazine -> www.samcoupe.com
Plus hardware for the ZX Spectrum, RC2014 and other general retro peripherals.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

Inbox has 5% but I hadn't read it yet.

BTW the mc10 emulator will also run on a SAM
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

Yesterday evening I wanted to continue when my “0”-key of the laptop didn’t work anymore.

i managed to repair it although the bounce up is now less working.
I might fix that later
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

Another opcode fixed, but there are still other bugs……
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

Next opcode repaired, BPL
Debugging goes slow but steady.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

I skipped a test on a register assuming 0 would be an irrelevant values. It turns out the ROM does a test on zero.
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

Almost correct ( no error anymore)

Image
Dr beep
Manic Miner
Posts: 387
Joined: Mon Oct 01, 2018 8:53 pm

Re: PROJECT : A TRS80 MC10 emulator on the ZX Spectrum

Post by Dr beep »

Some opcodes do a test on zero and other allways set carry.

Again an opcode repaired.
Post Reply