joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.83k stars 383 forks source link

PC-98 IDE emulation #1085

Open joncampbell123 opened 5 years ago

joncampbell123 commented 5 years ago

Is your feature request related to a problem? Please describe. Adapt IDE emulation for PC-98 mode to match real hardware

Describe the solution you'd like IDE emulation (primary and secondary only) in PC-98 mode.

According to documentation available, PC-98 maps IDE to INT3 (IRQ9) only, and both IDE controllers occupy the same I/O ports at 640h even. You select which IDE controller to talk to through I/O ports 430h, 432h.

Documented port 430h, 432h behavior says 00h is primary, 01h is secondary, and 80h is a dummy write to read status.

Real hardware behavior shows port 430h has value 41h (?), 432h has 20h (?). Whatever 8-bit value was last written to 432h is what is read back. There does indeed appear to be IDE-like I/O ports at 640h-64Eh even.

Adaptation of IDE emulation would mean that IRQ, IO and ALTIO settings would have to be ignored, IRQ locked at 9, and IDE emulation should not register I/O ports itself but instead register those fixed I/O ports that then pass through the I/O to the currently selected IDE controller according to port 430h (or 432h?).

The reason for implementing this is that it would allow bootable HDI images to load a CD-ROM driver and access the CD-ROM emulation in DOSBox-X PC-98 mode, in the same way an IBM PC/AT bootdisk in DOSBox-X could use an ATAPI IDE driver and access the CD-ROM drive.

joncampbell123 commented 5 years ago

See also:

http://hackipedia.org/browse.cgi/Computer/Platform/PC%2c%20NEC%20PC%2d98/Collections/Undocumented%209801%2c%209821%20Volume%202%20%28webtech.co.jp%29/io%5fide%2etxt

joncampbell123 commented 5 years ago

I guess being an 8-bit register the standard could probably support up to 64 IDE controllers but it's more realistic to assume a system with only two IDE connectors would only pay attention to bit 0.

joncampbell123 commented 5 years ago

Windows 98 on this same system shows the same I/O ports listed in the doc in the device manager as well as a memory range that probably corresponds to a BIOS of some kind.

giulioz commented 5 years ago

Could this be related to Policenauts not running? It needs CD and when executed from floppy it crashes, with this on console:

LOG: PC-98 INT 18 AH=42h CH=0xE0
LOG: PC-98 port 68h unknown command 0x02
LOG: PC-98 port 6Ah unknown command 0x41
LOG: PC-98 INT stub unknown call AX=1100 BX=0CBC CX=0CBC DX=2FC5 SI=2FEF DI=2FEF DS=13A8 ES=2FC5
LOG: PC-98 INT stub unknown call AX=0000 BX=0510 CX=0316 DX=7002 SI=1D7C DI=0FB0 DS=7202 ES=018E

When running another binary from the floppy (installer) I get this from console:

LOG:  702611665 ERROR MISC:MSCDEX: INT 2F AX=1500 BX=0000 CX=0AAC
LOG:  702611796 ERROR MISC:MSCDEX: INT 2F AX=150C BX=0000 CX=0AAC
LOG:  702611915 ERROR MISC:MSCDEX: INT 2F AX=1510 BX=0A90 CX=0010
LOG:  702611915 ERROR MISC:MSCDEX: Driver Function 03
LOG:  702611915 ERROR MISC:MSCDEX: IOCTL INPUT Subfunction 06
LOG:  702611915 ERROR MISC:MSCDEX: Status : 0100
LOG:  702612083 ERROR MISC:MSCDEX: INT 2F AX=1500 BX=0000 CX=0A90
LOG:  702612209 ERROR MISC:MSCDEX: INT 2F AX=1500 BX=0000 CX=0A90
LOG:  702612340 ERROR MISC:MSCDEX: INT 2F AX=1500 BX=0000 CX=0A90
LOG: PC-98 INT DCh unknown call AX=0000 BX=0000 CX=0012 DX=0DFC SI=0001 DI=0000 DS=0AFA ES=0DFC
LOG:  702612630 ERROR MISC:MSCDEX: INT 2F AX=1500 BX=0000 CX=0A90
LOG:  702612756 ERROR MISC:MSCDEX: INT 2F AX=1500 BX=0000 CX=0A90
LOG:  702612887 ERROR MISC:MSCDEX: INT 2F AX=1500 BX=0000 CX=0A90
LOG: PC-98 INT DCh unknown call AX=0000 BX=0001 CX=0012 DX=03E1 SI=0001 DI=0001 DS=0AFA ES=0060
LOG:  702613177 ERROR MISC:MSCDEX: INT 2F AX=1500 BX=0000 CX=0A90
LOG:  702613303 ERROR MISC:MSCDEX: INT 2F AX=1500 BX=0000 CX=0A90
LOG:  702613434 ERROR MISC:MSCDEX: INT 2F AX=1500 BX=0000 CX=0A90
joncampbell123 commented 5 years ago

It looks like it's trying to talk to the drive through MSCDEX.EXE which does not involve the IDE controller.

In DOSBox-X, the IDE controller is a hack that routes back around a minimal portion of MSCDEX.EXE, in fact.

Not sure about the INT DCh calls.

giulioz commented 5 years ago

May I fill a specific bug for this game?

joncampbell123 commented 5 years ago

@giulioz Go ahead. It seems to be MSCDEX.EXE related.

If you would like to look at it in the debugger try running "bpint 2f" and then running the game so you can examine what the game expects.