News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_HAL6128

Emulator detection

Started by HAL6128, 21:25, 29 September 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

HAL6128

Quote from: arnoldemu on 09:25, 30 September 15

My question:  What are you doing that doesn't work on emulators?

If you would share the code with me I can make sure my emulator works with your code and that I can tell other people how to make their emulators work better too :)
...it was just a thought to shorten things. I'm coding a small "filemanager" for the CPC which should do things in the same way like the Midnight-Commander (show directory entries, copy, move, etc.) for FAT32 Harddiscs attached on Symbiface or X-Mass (...uses the &FD0x ports). Some ATA-Commands (e.g. the device-identify command) or Registers are not supported by WinApe. If I could detect WinApe I could jump over some subroutines...
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

arnoldemu

#26
@HAL6128:

Question, does Winape give you an error condition when you try the commands it doesn't support?
Perhaps you can use that to detect it and the code is also valid to check for errors.

I think the ATA specification says that the commands *should* or *must* be supported but they can give errors if they are not.
The ATA specification is linked from the wiki article about Symbiface 2.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

TFM

No, that's not the case. You just wait for that bit to become '1' and it never does. So back to topic:


How to detect WinApe or Caprice? [nb]Once I did know that, but forgot, the programmer do know though. I clearly remember there is a way for winape, I used that in FutureOS system 5. a decade ago, but it's not there any longer, since not needed.[/nb]
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Bryce

How about:

10 INPUT "Are you running this on an emulator (Y/N)";A$
20 IF A$="n" or A$="N" THEN GOTO 100
30 PRINT "Sorry this doesn't work on emulators."
40 END

:)

Bryce.

P.S: That's the upper limits of my programming skills!

||C|-|E||


TotO

Simple and clever. Will always work!
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

HAL6128

#31
Quote from: arnoldemu on 09:31, 01 October 15
@HAL6128:

Question, does Winape give you an error condition when you try the commands it doesn't support?
Perhaps you can use that to detect it and the code is also valid to check for errors.

I think the ATA specification says that the commands *should* or *must* be supported but they can give errors if they are not.
The ATA specification is linked from the wiki article about Symbiface 2.

I don't know if there's an error feedback. (I should read the specification!). The command works but the buffer in RAM is only filled with &FF instead of reasonable datas.
And yes, what a good idea... this could be a detection if the whole checksum for the sector is &FF. I had just tested the command with the emulators (WinCPC and WinApe) and they both return &FF. Let me check if the command will provide the same result on real hardware with NO X-MASS attached.
Thanks for the leading thoughts!

@Bryce : yes, I had your solution also in mind, honestly :)
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

TFM

Quote from: Bryce on 15:46, 01 October 15
10 INPUT "Are you running this on an emulator (Y/N)";A$
20 IF A$="n" or A$="N" THEN GOTO 100
30 PRINT "Sorry this doesn't work on emulators."
40 END


RUN
Are you running this on an emulator (Y/N) N

Line does not exist


:doh:
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

TotO

"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

HAL6128

Ok, the "device_identify" command could work. On real hardware and no IDE interface attached the buffer is filled &FF and &F7 in random order. So a checksum over the first 16 bytes will be different to an emulators which is always &FF (at least tested with WinCPC, WinApe, Caprice and JavaCPC)...
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

arnoldemu

Quote from: HAL 6128 on 20:28, 02 October 15
Ok, the "device_identify" command could work. On real hardware and no IDE interface attached the buffer is filled &FF and &F7 in random order. So a checksum over the first 16 bytes will be different to an emulators which is always &FF (at least tested with WinCPC, WinApe, Caprice and JavaCPC)...
Are you detecting if symbiface 2 or x-mass is connected?
Or are you detecting if ide drive is connected or not?

I would not assume to read 0x0ff or 0x0f7. This may just be bus noise. It is best if you check if sector/track register can be written and read back and that status register has expected bits (e.g. busy) and that when you write a command (identify is good), that the bits change to show command is being executed, and then check the status to see result looks good.
You should also check if drq is set, this will tell you if bits are ready to read or not. This will then tell you there is a symbiface or x-mass device attached.
If you see a problem, best to tell Richard to fix it ;)

I think better to do this than to expect the buffer to be specific values because it may not always be true like this.

I am guessing that symbiface 2 doesn't buffer the sector, the buffer is on the ide device. Symbiface 2 is like a i/o port decode and pass through the data to the ide device.

The ATA spec is here, all commands are described here (later specs describe SMART and features like this):

http://www.t13.org/documents/UploadedDocuments/project/d1153r18-ATA-ATAPI-4.pdf

Symbiface 2 registers are here:

SYMBiFACE II:IDE registers - CPCWiki


My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Bryce

Quote from: TFM on 15:33, 02 October 15

RUN
Are you running this on an emulator (Y/N) N

Line does not exist


:doh:

Of course. His main routine needs to start at 100!

Bryce.

HAL6128

#37
Quote from: arnoldemu on 20:37, 02 October 15
Are you detecting if symbiface 2 or x-mass is connected?
Or are you detecting if ide drive is connected or not?

I would not assume to read 0x0ff or 0x0f7. This may just be bus noise. It is best if you check if sector/track register can be written and read back and that status register has expected bits (e.g. busy) and that when you write a command (identify is good), that the bits change to show command is being executed, and then check the status to see result looks good.
You should also check if drq is set, this will tell you if bits are ready to read or not. This will then tell you there is a symbiface or x-mass device attached.
If you see a problem, best to tell Richard to fix it ;)

I think better to do this than to expect the buffer to be specific values because it may not always be true like this.

I am guessing that symbiface 2 doesn't buffer the sector, the buffer is on the ide device. Symbiface 2 is like a i/o port decode and pass through the data to the ide device.
I've detected it without any device attached on the CPC. Just the plain CPC.

I think it's what you said and TotO mentioned. The CPC is not perfect (versus the Emulator). I mean the noises around the extension bus or the drive belt speed variation during action.

Although the IDE emulation is not perfect it's not a problem. I'm glad that WinApe has at least one working.

But you are right. The proper way is using the status register and read them. This is normally what the PC does during BIOS boot.

The status register from WinApe deliver "&x11111111" whereas on a real CPC (with a X-Mass attached) it's "&x00000101". At least it says that DRQ = 0 (which should be as the spec describes), but ERR = 1, which worries a little bit because spec says it should also be cleared.
(Just a thought, maybe this register value could be the problem why BonnyDOS hangs in WinApe during initialising the ROM because it does something like a device identify???)

And yes, the sector (either reading, writing or device identify) will buffered by the ide device and you just have to  "INI" or "OUTI" it 512 times to RAM. The principle is the same X-MASS or Symbiface.
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

AMSDOS

The program @Bryce provided is great, the trouble is punishing any Liars who want to fool it, unfortunately the suggestion I offered earlier crashes on a Real Amstrad. I presume the object here is to punish the Emulator user?
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Bryce

Quote from: AMSDOS on 00:40, 05 October 15
The program @Bryce provided is great, the trouble is punishing any Liars who want to fool it, unfortunately the suggestion I offered earlier crashes on a Real Amstrad. I presume the object here is to punish the Emulator user?

Then how about:

10 INPUT "Are you running this on an emulator (Y/N)";A$
20 IF A$="n" or A$="N" THEN GOTO 100
30 PRINT "Sorry this doesn't work on emulators."
40 Load "Airwolf"

Bryce.

AMSDOS

Quote from: Bryce on 08:28, 05 October 15
Then how about:

10 INPUT "Are you running this on an emulator (Y/N)";A$
20 IF A$="n" or A$="N" THEN GOTO 100
30 PRINT "Sorry this doesn't work on emulators."
40 Load "Airwolf"

Bryce.


Followed by:


SAVE"emtst.bas",p


:laugh:
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

TotO

Line 40 ? Airwolf only for emulator users! :-\
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Devilmarkus

Best:
Make a check:
Press CTRL, SHIFT + ESC to continue ;)
(PC can handle max. 2 keys simulteanously, perhaps 3, but this combination is impossible)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Bryce

Quote from: TotO on 09:51, 05 October 15
Line 40 ? Airwolf only for emulator users! :-\

Well AMSDOS said he wanted them to suffer. You can replace Airwolf with any other CPC disaster you care to choose.

Bryce.

TotO

Quote from: Devilmarkus on 11:00, 05 October 15(PC can handle max. 2 keys simulteanously, perhaps 3, but this combination is impossible)
On R-Type, a hidden screen is shown if you press 'S' 'P' 'C' 'Y' simultaneously when loading.
Originally, it was 'S' 'P' 'E' 'C' 'Y', but it reported to not work on emulators...  ;)
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Devilmarkus

Quote from: TotO on 12:49, 05 October 15
On R-Type, a hidden screen is shown if you press 'S' 'P' 'C' 'Y' simultaneously when loading.
Originally, it was 'S' 'P' 'E' 'C' 'Y', but it reported to not work on emulators...  ;)

It's because the keyboard clash in real hardware.
No emulator (except JavaCPC, and I think, Kevin added it to Arnold) emulates this yet...
In JavaCPC you can press combinations with virtual keyboard  :laugh: :P
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

arnoldemu

Quote from: Devilmarkus on 13:12, 05 October 15
It's because the keyboard clash in real hardware.
No emulator (except JavaCPC, and I think, Kevin added it to Arnold) emulates this yet...
In JavaCPC you can press combinations with virtual keyboard  :laugh: :P
Yes I added it to the "mythical" Arnold wip ;)
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

arnoldemu

Quote from: HAL 6128 on 19:26, 03 October 15
I've detected it without any device attached on the CPC. Just the plain CPC.

I think it's what you said and TotO mentioned. The CPC is not perfect (versus the Emulator). I mean the noises around the extension bus or the drive belt speed variation during action.

Although the IDE emulation is not perfect it's not a problem. I'm glad that WinApe has at least one working.

But you are right. The proper way is using the status register and read them. This is normally what the PC does during BIOS boot.

The status register from WinApe deliver "&x11111111" whereas on a real CPC (with a X-Mass attached) it's "&x00000101". At least it says that DRQ = 0 (which should be as the spec describes), but ERR = 1, which worries a little bit because spec says it should also be cleared.
(Just a thought, maybe this register value could be the problem why BonnyDOS hangs in WinApe during initialising the ROM because it does something like a device identify???)

And yes, the sector (either reading, writing or device identify) will buffered by the ide device and you just have to  "INI" or "OUTI" it 512 times to RAM. The principle is the same X-MASS or Symbiface.
My advice is to make it work with the real device. Emulators should be fixed :)

With Arnold WIP, when I implemented Symbiface 2 IDE I didn't test it against a real HD yet. That is my next plan - but I needed to finish testing the Kempston Mouse first.
I followed the ATA spec and I tested it against SymbOS and BonnyDOS.

BonnyDOS works on Arnold WIP, I can partition, format and use it. :)

SymbOS partially works but because I didn't have an appropiate MBR setup on my emulated hard disc it didn't recognise the disc. I haven't yet implemented reading/writing of hard disc images which I need to do. When I've done that I'll support Winape's IDE file structure (which Richard has described to me :) ).

So I'll be testing on real HD and making it closer to that. I believe it's the ONLY way to get an accurate working emulation.

(I have also implemented Dobbertin HD and Vortex HD in Arnold WIP, both are experimental because I don't have access to the hardware to test them as much as I would like to).

I am also suprised that the status register is reporting an error. ATA Spec also says it's reporting something in an unused bit. Looking at an earlier specification (ATA-1):

http://www.t13.org/documents/UploadedDocuments/project/d0791r4c-ATA-1.pdf

The status register is reporting:

1. ERR
2. CORR - Corrected Data. A correctable data error was encountered and the data has been corrected.

When the drive (or in this case the plugin Drive module in the X-MASS) is reset it performs a startup sequence. In this startup sequence perhaps it encountered this recoverable error and signalled it?
I don't really know enough about the startup sequence for HD drives.

What value does the Error register return? This should tell you more.


My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

HAL6128

Your emulator WIP sounds very promising. Maybe TFM can help with the Dobbertin HD testing?

Interesting ATA spec!

For a future vision I also want to support partitioned drives connected to the Symbiface. The X-MASS DOM supposed not to be partitioned (and won't make sense) and it's more efficient to handle it with a FAT16 file system (as TotO and SyX intend) with their ACMEDOS.

At the moment I try to copy parts of a real HD-Image into WinApe IDE File with the help of a Hex-Editor. The first sector starts at &a00. For testing purposes I fill this sector with a MBR datas.

I didn't check the Error Status register so far. This will be my next step. Maybe I also did a programing failure. I only asked the Status Register once. I found an article on ATA PIO Mode - OSDev Wiki which explained some booting details. I should poll the Status Register until reaching the right status!?

Let me see.
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

TFM

I will have access to my HD20 at X-MASS, but I know that other people in the forum own one. If a hard-disc-image or something like this is needed then let me know, so I can write a backup tool / disc image creator or something.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Powered by SMFPacks Menu Editor Mod