VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

I noticed that recently some 8086 software started having bugs. I tried to run Prince of Persia(MS-DOS), but once if starts the cinematic with the princess and the evil wizard, the left half of the screen looks OK, but the right half contains garbled data? The testsuite I'm using from fake86 still checks out correctly, except for the MUL instructions, which contains undefined behaviour on other flags than the Carry/Overflow flags(actually more like undocumented and seemingly top-secret flag behaviour it seems). Primarily problems with bit 6 and another bit in the flags.

Last edited by superfury on 2016-12-08, 14:52. Edited 2 times in total.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 1 of 7, by superfury

User metadata
Rank l33t++
Rank
l33t++

I've made some little screen captures of the opening animation of Prince of Persia (MS-DOS version):

304-POP_PrincessAnimationStarts.jpg
Filename
304-POP_PrincessAnimationStarts.jpg
File size
269.61 KiB
Views
494 views
File comment
Animation starting during the Prince.exe opening animation, showing the princess and flames correctly, background is messed up.
File license
Fair use/fair dealing exception
305-POP_PrincessAnimationWizard.jpg
Filename
305-POP_PrincessAnimationWizard.jpg
File size
269.39 KiB
Views
494 views
File comment
Animation is running. The wizard and the hourglass show up correctly, background still incorrect.
File license
Fair use/fair dealing exception

It's running on the NEC V20/V30 CPU(Essentially just a 80186 in a PC XT).

Source code of the used CPU-specific functionality, implementations of the 8088/80188 cores:
https://bitbucket.org/superfury/unipcemu/src/ … 086.c?at=master
https://bitbucket.org/superfury/unipcemu/src/ … V30.c?at=master

It's used with 8-bits bus size, 80188 instructions(8086 and NECV30 core combined).

Anyone can see or knows what's going wrong here?

Edit: Currently, after some testing, it seems this is caused by the MIDI rendering screwing up the game somehow(on the NEC V30(actually 80186 without other enhancements than the new instructions) emulation)?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 2 of 7, by superfury

User metadata
Rank l33t++
Rank
l33t++

I also seem to notice that, besides the MIDI emulation(using Soundfonts) messing up the CPU emulation somehow, Windows 3.0 refuses to boot correctly (ending up at the opcode 66h again, which is invalid on the 80286). It's using the VGA on a 80286 8MHz AT(With VGA BIOS and XT-IDE AT BIOS).

Anyone knows what might go wrong? It works without problems on the XT emulation?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 3 of 7, by superfury

User metadata
Rank l33t++
Rank
l33t++

I've just tested the XT 80186(Reported as NEC V20/V30 depending on 8/16-bit bus) emulation with the hardware passing the MIDI commands through to the OS(Windows 10). Sound works without problems, but when the (Dosbox version adjusted)MPU-401 is used(passing through to Windows, essentially the same thing Dosbox does) the output of Prince of Persia is messed up?

304-POP_PrincessAnimationStarts-WindowsMIDIPassthrough.jpg
Filename
304-POP_PrincessAnimationStarts-WindowsMIDIPassthrough.jpg
File size
225.24 KiB
Views
442 views
File comment
Prince of Persia MS-DOS on 80186 XT PC emulation(UniPCemu latest commit). Display is messed up with Dosbox MPU-401 emulation enabled only?
File license
Fair use/fair dealing exception

Edit: Oh, btw, the MPU-401 is hardwired to IRQ 9. I don't know if that causes any problems (Since IRQ9 isn't used normally on the XT)

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 4 of 7, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie

I don't understand how it could work, as XT has only single PIC so it does not have IRQ9. So on an XT, MPU401should be IRQ2.

But on an AT, the ISA IRQ2 wire is replaced with IRQ9 wire which is software routed to IRQ2 vector so no program using IRQ2 should notice the difference.

Reply 5 of 7, by superfury

User metadata
Rank l33t++
Rank
l33t++

What about the other AT hardware present on the XT as well in UniPCemu? In this case the ATA HDD controller? It uses IRQ 14&15 on the AT, but what about the XT? What IRQ should it be connected to?

Edit: The MPU-401 is now routed to IR line 2 instead of 9 on the XT. What line should I connect the XT-IDE controller to? The Serial IRQs (4-5), since they have a detect register for raised interrupts?

Edit: I've remapped the Primary and Secondary XT IDE Controllers to share IR line 5(as found in an IRQ list). The IDE controllers CAN share the IR lines, don't they?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 6 of 7, by superfury

User metadata
Rank l33t++
Rank
l33t++

After modifiying the IDE controller to use IR line 5 (shared with the second IDE controller, if any) and modifying the MPU-401(A copy modified from Dosbox's emulation) to use IRQ 2 on XT architecture, Prince of Persia goes wrong even more: at the point the princess turns around, she disappears and the game hangs.

Anyone knows what's going wrong? The XT-IDE BIOS seems to continue as normal(even booting correctly), so the IRQ line being IR5 now shouldn't be a problem?

Edit: I've just removed all PC/XT hacks(which also enable the second PIC controller non-existant on real PCs). The video now continues (although with the part from after the carpets on the floor until the right side of the screen being noise data, except for the flame animations and princess, wizard and hourglass). After continuing to the final screen before starting, pressing space(or any other key) hangs the app once again.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 7 of 7, by superfury

User metadata
Rank l33t++
Rank
l33t++

After looking at the Dosbox MPU-401's MPU401_Event function(which runs in a seperate thread), it doesn't use ANY locks. That could cause some corruption in the application due to both threads accessing the MPU emulation, causing corruption? It would need to be moved to the main thread instead.

Edit: Moving it to the main thread fixes that issue, but Prince of Persia is still buggy at that point. Anyone knows what might be the cause(Fixing the IRQ handler done on the UART seems to fix the mouse bug that's been around since I've implemented the 80286 😀 Now the mouse works properly again(With modern IRQs and full 8-bit range(instead of the previous 7-bit range(-64 to +64 range in 8-bit signed values) used in all releases up till now). )?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io