TurboR

Door PingPong

Prophet (4093)

afbeelding van PingPong

29-04-2008, 20:53

the TurboR has two cpu. But only one is active at any time.

When the TurboR boot witch CPU is active?
If it's the R800 what ensures the compatibility on the z80?
(means:How can the TurboR automatically recognize and switch to the z80 when running a msx1/2/2+ SW)

Aangemeld of registreer om reacties te plaatsen

Van ARTRAG

Enlighted (6923)

afbeelding van ARTRAG

29-04-2008, 20:56

IIRC TurboR boots in z80 mode.
Applications have to switch to R800 with a system call.

Van dvik

Prophet (2200)

afbeelding van dvik

29-04-2008, 20:58

If I understand correctly its one CPU with two modes and two register banks, right? One mode is compatible with the Z80 including timing. Iirc, the CPU always starts up in Z80 mode and then you can switch to R800 mode. You can run most games in R800 mode if you switch before the game starts.

Van PingPong

Prophet (4093)

afbeelding van PingPong

29-04-2008, 21:14

IIRC TurboR boots in z80 mode.
Applications have to switch to R800 with a system call.

was my first idea effectively, but why when i run an emulated r800 the computer go in basic in a very fast speed ? (so R800) even the bootup logo is fast...

It's the TurboR BIOS that switch on the R800 just before going in basic?

Van NYYRIKKI

Enlighted (6016)

afbeelding van NYYRIKKI

29-04-2008, 21:17

AFAIK when MSX tR boots Z80 is active. In early boot routine tR is booted again using R800 in order to make PC-register equal to both CPUs.

What comes to applications, all applications are executed in Z80 mode. Only exeption is that if MSX-DOS2 / Disk Basic 2.x environment is detected, CPU mode will be changed to R800 DRAM. This detection is made by examining disk bootsector.

dvik: No, they are physically different CPU's with different timings. For example R800 does not obey HALT-line activated by Pause-key.

Van dvik

Prophet (2200)

afbeelding van dvik

29-04-2008, 21:23

No, they are physically different CPU's with different timings.
Ah cool, but its not possible to use both CPUs at the same time, right, so I suppose they share some resources or?

I think some emulators can show whether the R800 is enabled (I'm not 100% sure but I think there is a little led in bluemsx showing it and in openmsx I think there is a shell command to check it)

Van turbor

Hero (519)

afbeelding van turbor

29-04-2008, 21:48

Ok, purely from memory here:

It is the MSX engine chip that decides which cpu is active and the other one will be halted.
There is an extra flip-flop available to see if the machine is cold booted.
During a cold boot one of them (don't know which one is active ) will run the bios up until a block where this flipflop is tested and if needed toggled and the msxengine is instructed to switch cpu, the other cpu will then start to run. And since it is just booted it will be starting from address 0 and when it comes to the same block the flipflop is checked again so no second reboot is done.
The code that does this is in the cpu switch bios code, so that at this point you know the internal registers of and (most importantly) the ram addresses in the PC register. Each time you now call the cpu switch routine you know that the cpu is in this exact part of code execution so you can easily and safely switch from R800 to Z80 and back again.
IIRC it is possible to switch the CPU bu using some out instructions to the msx-engine. But if you do it then the R800 regs (and most importantly its PC register) will differ from the one in the Z80.

So you could make it a challenge to come up with some code that does the switching while keeping the z80 in a separate state then R800 but I leave that excercise up to you Smile
Maybe you can change #rst38 in memory and use the switch to have the z80 do a special interrupt routine which at the end switches back to the R800 or something. Tongue

Van NYYRIKKI

Enlighted (6016)

afbeelding van NYYRIKKI

29-04-2008, 21:52

The led is controlled by software. I'm not 100% sure R800 stops JUST at the moment the flip-flop switch (controlled by I/O) is changed. Actually I think that it stops to next memory I/O, but this is just speculation based on CPU switch routine examination....

For sure R800 and Z80 uses same RAM and I/O, but otherways they do not share resources.

turbor: CPU switch is actually quite a slow process. It is not recommended to do it every once in a while...

Van turbor

Hero (519)

afbeelding van turbor

29-04-2008, 22:05

CPU switch is actually quite a slow process. It is not recommended to do it every once in a while...

If you use the bios it must be slow due to all the overhead of storing and reloading cpu regs and the interslot calls. Are you saying that it is slow in itself when you toggle the flip/flop by directly sending the I/O commands ?
Can you give a raw estimate of the time it needs ?

Van NYYRIKKI

Enlighted (6016)

afbeelding van NYYRIKKI

30-04-2008, 10:29

Yes, the CPU change is slow also trough I/O, but I don't remember the exact details (results of my tests should be hidden somewhere here in MRC, but I didn't find them now)

IIRC CPU change took about same time as it takes to execute 500 T-states on Z80. (In the tests I assumed that Z80 -> R800 change takes same time as R800 -> Z80)

I made it hard way using direct I/O, but actually testing can be quite easy... These are the steps actually needed:

A) How many times you can execute R800 -> R800 BIOS call in a second?
B) How many times you can execute Z80 -> Z80 BIOS call in a second?
C) How many times you can switch CPU in a second?

If we think about this C should be about (A+B)/2 but unfortunately it is not...