Big PCem patchset

Discussion of development and patch submission.
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Big PCem patchset

Post by SA1988 »

Here's my patchset combined with Battler's one, and actually with more commentary about why those fixes are there.
Improvements:
1) Added REP NOP instruction, required by Windows 2000 to function properly.
2) Proper keyboard handling using the host keyboard layout, fixes some issues with Japanese, Brazilian, Korean and other Asian keyboards and other non-PC keyboards.
3) Added IBM AT 8Mhz Model with suitable roms, improves speed of the IBM AT.
4) Re-organized video card selection (made an enumerator to match the main machine romset).
5) Major improvements to the IDE CD-ROM emulation, added ATAPI command 0x25, required by NT 3.1, 4.0 and Windows 2000.
6) Fixed crash when formatting with NT 3.1's built formatting tool.
7) Fixed BIOS Date as some software is sensitive about it on newer emulated machines.
8) S3 Trio emulation greatly improved, interlace problem fixed (reporting refresh rate of 43Hz instead of 85Hz), 1024x768x32bpp works properly now (Phoenix S3 BIOS only).
9) The "Unknown ramdac" color depth configuration corrected, at least fixes issues with non-8bpp and non-4bpp color depths of the ET4000.
10) Data segmentation failure corrected (commented out), fixes IBM OS/2 1.2 booting to install and main execution after installation.

http://towg.tk/Emulators/SRC-patches/pcem-patches.diff
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Separate patches, please! Big patches are an utter nightmare to work with. Make my life easier, and your patches are more likely to be merged in!
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: Big PCem patchset

Post by SA1988 »

ok, gonna make separate ones, and I'm also fixing the DOS/V issue (probably some sort of CRTC issue).
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Few initial comments :
2) Proper keyboard handling using the host keyboard layout, fixes some issues with Japanese, Brazilian, Korean and other Asian keyboards and other non-PC keyboards.
I did ask Battler to rework this, I'm assuming it hasn't been done? I'd prefer Battler's patches to come through Battler rather than you.
6) Fixed crash when formatting with NT 3.1's built formatting tool.
You haven't fixed this, you appear to have just hacked around the issue. Read/write multiple with a blocksize of 0 is illegal and NT shouldn't be trying it, so you need to figure out why this command is being sent rather than disabling the check.
9) The "Unknown ramdac" color depth configuration corrected, at least fixes issues with non-8bpp and non-4bpp color depths of the ET4000.
I'm assuming you're basing this on the Windows 9x driver, in which case have you identified what RAMDAC this actually is? I'm assuming that as a side-effect TLIVESA1 no longer works.
10) Data segmentation failure corrected (commented out), fixes IBM OS/2 1.2 booting to install and main execution after installation.
[/quote][/quote]
As with 6), this is a hack not a fix and I will not take this in its current state.

There are some other obvious issues (eg the DOS/V 'fix' looks completely broken at first glance) but I will comment on these later.
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: Big PCem patchset

Post by SA1988 »

the DOS/V one makes it recognize which hardware scrolling method is used and, without those lines, it gets an infinite loop (according to Battler) at trying to detect which /HS scrolling to detect, and no need to be harsh towards him, people are trying their best to improve your emulator for the greatest PC emulator ever.
And if those fixes will not get accepted, I would rather create another fork based on your main emulator. (and that's why I dropped the keyboard handling in those 4 separate patches)
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: Big PCem patchset

Post by Battler »

TomWalker wrote:I did ask Battler to rework this, I'm assuming it hasn't been done? I'd prefer Battler's patches to come through Battler rather than you.
I did and I replied to your PM on Vogons. Let me repost it here (with URL's updated to match current domains):

A patch to the previous patch (three actually, sorry for that, my fault, and I have no idea how to merge them into one single patch):
http://proxima.ringoflightning.net/96.patch ;
http://proxima.ringoflightning.net/97.patch ;
http://proxima.ringoflightning.net/98.patch .

Your points 1, 2, and 4 should be addressed by this, as well as the device_t etc. part of point 3. Also, I know CRTC 0x36 is read/write, and even my modification respects that, except for the video memory bits. I did that because otherwise it would always return 2 MB for a trio, regardless of how much RAM it has, and i think the "0 MB" bug with the Bahamas64 in 8 MB mode is also caused by the same problem. Something reports the wrong video memory amount to the BIOS which then resets CRTC 0x36 to the wrong value (confirmed when I had it debug all video port I/O - the video BIOS was writing back to 0x36 with modified video RAM values). The only way I found to fix that was to make the code force the VRAM bits to be correct for the specific emulated video card and RAM quantity.

As for DOS/V, one or more of the I/O calls done by the display driver to detect the supported hardware scrolling method in the unpatched PCem evidently doesn't return the correct value, causing the DOS/V display driver (JDISP.SYS) to not react correctly and end up in an infinite loop. SA1988 fixed that by modifying PCem's handling of some I/O reads and writes to match those of DOSBox-X in which DOS/V works fine.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Sorry, must have missed that PM somehow.

I've cleaned up the keyboard changes, however as I only have UK keyboards I can't really test it. Do you mind testing it before I commit it?
Attachments
rawinput.patch
(35.8 KiB) Downloaded 454 times
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: Big PCem patchset

Post by SA1988 »

Well I can test it for you :)
Edit: misread the post, sorry, I don't have any Japanese keyboards :( and, about win-mouse.cc, in that commit, looks like it can't compile fine because DirectInputCreate was not declared.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: Big PCem patchset

Post by Battler »

- TomWalker: Be sure to declare DirectInputCreate in win-mouse.cc when using the keyboard patch, because it was originally declared in win-keyboard.cc but the patch removes that.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Compiles fine for me...

Will have another look tomorrow.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Very slight tweak, let me know if it works...
Attachments
rawinput.patch
(35.83 KiB) Downloaded 439 times
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Slowly working my way through these...
SA1988 wrote:1) Added REP NOP instruction, required by Windows 2000 to function properly.
3) Added IBM AT 8Mhz Model with suitable roms, improves speed of the IBM AT.
4) Re-organized video card selection (made an enumerator to match the main machine romset).
Committed.
5) Major improvements to the IDE CD-ROM emulation, added ATAPI command 0x25, required by NT 3.1, 4.0 and Windows 2000.
Either you've missed some changes out of the patches, or your fix for this is a tad broke - total_sectors and len are never set, and buf is never allocated. Also you have command 0xad also using the same code, which I'm not sure is intentional.
6) Fixed crash when formatting with NT 3.1's built formatting tool.
A quick test suggests this may be related to your change to IDE_TIME. Remind me what changing that define fixed?
7) Fixed BIOS Date as some software is sensitive about it on newer emulated machines.
Which software? Also, I don't think this change is in the individual patches.
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: Big PCem patchset

Post by SA1988 »

well, I'm about to "re-configure" the 0x25 one, but the nvr one is optional, so feel free to include or not, it's a personal patch ;)

And there's an issue with reading the CD-ROM under OS/2 Warp (3.0 and 4.0), it doesn't show info in the log, OS/2 Warp just sits there asking for the CD where, actually, is inserted; pressing Enter did not change anything.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

I've seen the OS/2 Warp CD issue, it's somewhere on my todo list.

Phoenix Trio32 is in, I did rework a few bits. I haven't added the Trio64 variant as I don't have the BIOS, so can't test it.
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: Big PCem patchset

Post by SA1988 »

[EDIT] the 86c764x1.zip one is the right Trio64 variant. ;)

[Moderator edit - no links to ROM images please - it's not entirely legal]
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Not sure what adding the Phoenix Trio64 would achieve - it's basically identical to the 9FX, right down to the BIOS-imposed 2 MB limit.
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: Big PCem patchset

Post by SA1988 »

TomWalker wrote:Not sure what adding the Phoenix Trio64 would achieve - it's basically identical to the 9FX, right down to the BIOS-imposed 2 MB limit.
well that Phoenix Trio64 bios in that edited link gives the full 4mb of vram unlike the 9FX.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: Big PCem patchset

Post by Battler »

TomWalker wrote:Not sure what adding the Phoenix Trio64 would achieve - it's basically identical to the 9FX, right down to the BIOS-imposed 2 MB limit.
No, the Phoenix Trio64 BIOS does NOT limit to 2 MB, it supports up to 4 MB. The 2 MB limit happens in PCem due to a bug somewhere in PCem's code that causes the BIOS to think there are only 2 MB VRAM. In my patchset, I worked around it by fixing the VRAM bits of CRTC 0x36 to the correct values, and there were no problems. Even Windows 3.1 worked fine at 1024x768x32-bit color with the Trio64 driver. In fact, the mere fact that driver, which is for the 764, even lists resolutions such as 1024x768x32-bit color, shows the Trio64 could go up to 4 MB VRAM. The BIOS itself also has code for correctly detecting 4 MB VRAM and reporting it to VESA accordingly, and the Windows 3.1 driver also detects 4 MB VRAM correctly. I think the problem could be in the RAM DAC.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: Big PCem patchset

Post by Battler »

TomWalker wrote:Very slight tweak, let me know if it works...
I took a look at it, and it seems to me it should work, as the code looks as it should, and does not differ much from my original.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Okay, disassembling the BIOS suggests it may only support 4 MB with FPM, not EDO. Will look at this later...
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Yes, FPM only. This is actually stated in section 7 of the Trio32/64 datasheet. Apparently the RAS1 pin (used to select the last 2 MB of RAM) gets used as an output enable with EDO. Presumably this was allowed because no-one circa 1995 was going to make a 4 MB card and only put a Trio64 on it.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: Big PCem patchset

Post by Battler »

- TomWalker: Would it be possible to somehow use FPM in the emulated Trio64?
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

I just added that a couple of hours ago.
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: Big PCem patchset

Post by SA1988 »

nice :)
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: Big PCem patchset

Post by Battler »

- TomWalker: Ok, I just tested, your latest revision of the keyboard raw input patch works correctly, all scan codes get passed to the guest OS correctly.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Any good reason for why RIDEV_NOLEGACY was set? It prevents using the keyboard to navigate menus and dialogs - particularly important when trying to create a hard disc...
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: Big PCem patchset

Post by SA1988 »

TomWalker wrote:Any good reason for why RIDEV_NOLEGACY was set? It prevents using the keyboard to navigate menus and dialogs - particularly important when trying to create a hard disc...
Ah, that was the reason why I couldn't type properly in the settings of PCem! Thanks for this fix! :D
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: Big PCem patchset

Post by SA1988 »

thanks for your implementation of the read capacity command on ide.c on PCem, but it still can't find the CD (I'm using Warp 3) and I'm even mounting it with Daemon Tools (also tried with MagicDisk, same result) with the built-in IDE CD-ROM drivers from Warp 3 (I was doing the CD install).
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Big PCem patchset

Post by SarahWalker »

Sorry, I only have Warp 4.
Post Reply