joncampbell123 / dosbox-x

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

PC-98: Port 0x42 is not implemented #903

Closed hdk1983 closed 6 years ago

hdk1983 commented 6 years ago

I/O port 0x42 is not implemented. The port is currently always read as 0xff but it should be status including system type and system clock. Because of this bug, BGM speed and tone in the following freeware games are incorrect if 5MHz of PIT master clock is selected:

debug_000

joncampbell123 commented 6 years ago

I see why I missed it... the Undocumented PC-98 reference lists it under "PRN" (printer).

https://web.archive.org/web/20180627150454/http://hackipedia.org/browse/Computer/Platform/PC%2C%20NEC%20PC%2D98/Collections/Undocumented%209801%2C%209821%20Volume%202%20%28webtech.co.jp%29/io%5Fprn%2Etxt

https://translate.google.com/translate?sl=ja&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=https%3A%2F%2Fweb.archive.org%2Fweb%2F20180627150454%2Fhttp%3A%2F%2Fhackipedia.org%2Fbrowse%2FComputer%2FPlatform%2FPC%252C%2520NEC%2520PC%252D98%2FCollections%2FUndocumented%25209801%252C%25209821%2520Volume%25202%2520%2528webtech.co.jp%2529%2Fio%255Fprn%252Etxt&edit-text=

(the link to Hackipedia is to the Wayback machine because GoDaddy's CGI script handling seems to have broken)

joncampbell123 commented 6 years ago

It seems to be common in PC-98 architecture to put a 8255 somewhere for a primary purpose, then use the unused ports for unrelated status and control.

Port B for the 8255 used for the printer in this case for example.

Or the unused 8255 port on the mouse interface.

joncampbell123 commented 6 years ago

Hold on, the list refers to 40h-46h even twice.

Either 42h in is the printer status, or 42h in is unrelated system status. It can't be both.

hdk1983 commented 6 years ago

The second part of the undocumented_mem/io_prn.txt is for ハイレゾ (hairezo, high-resolution) mode. The games that read the port for detecting system clock are for normal mode.

joncampbell123 commented 6 years ago

@hdk1983 Following up with our prior discussion of "high resolution" vs "super high resolution", does port 42h follow the PRN status definition in "super high resolution" or just "high resolution".

This is following the definitions where:

normal mode = 15khz 200-line mode high resolution = 24/31khz 400/480-line mode super high resolution = ?khz 1120x750 mode

If port 42h is normal PRN status in "high resolution" mode, then the same games will fail on normal PC-9801/9821 hardware because they will misread printer port status lines as bits that indicate system configuration.

Unless, there is some other bit elsewhere to select between both meanings of port 42h.

joncampbell123 commented 6 years ago

According to the documentation here:

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%5fprn%2etxt

PC-98 "high resolution" (not super high resolution, right?) makes port 42h normal PRN status.

I may have to make port 42h selectable as a dosbox.conf option, between PRN status and system config, to accomodate those games.

hdk1983 commented 6 years ago

PC-98 "high resolution" (not super high resolution, right?) makes port 42h normal PRN status.

It's "ハイレゾ", its resolution is super high resolution...

normal mode = 15khz 200-line mode high resolution = 24/31khz 400/480-line mode super high resolution = ?khz 1120x750 mode

Modes are named as:

However resolution of the high resolution mode is super high resolution, that term is normally not used, but only used in Wikipedia for describing it is different from the 高解像度, high resolution, of the normal mode. When ハイレゾモード was released, ハイレゾ term might be used only for PC-98 series in Japan, so many Japanese speakers using the ハイレゾ term might not think about that ハイレゾ was a abbreviation for high resolution and the same meaning as 高解像度. So if you find ハイレゾ in documentation, normally it means the 750 lines mode. If you use a translator, maybe you need to look at the original sentense of "high resolution".

A display for 15kHz is called as 標準ディスプレイ、a standard display. The 15kHz mode was normally not used. That might be used in early 1980s, because its display might compatible with other PCs like Sharp X1 and Fujitsu FM-7, but I've never seen PC-98 systems that are connected with such displays in 1990s.

joncampbell123 commented 6 years ago

Printer 8255 interface added to ports 40h-46h even, including port 42h with system configuration.

The printer part is not yet functional, but port 42h is there for any game that reads it.

Can you pull the latest commit and compile from source to verify this?

hdk1983 commented 6 years ago

Yes. It looks working properly. Tested on commit 2da77892c5f36486ab078adc97d1e10527e378e7.

debug_000