VOGONS


A different kind of emulator

Topic actions

First post, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

(This could be under Release Announcements however not yet as I am not yet releasing it as such until I figure out something about the sourcecode. This is more of a technical annoucement for now).

It all started with this (from Scali) a bit more than 6 months ago:

vladstamate wrote:
Ok, Scali, that is it, challenge accepted! :) […]
Show full quote
Scali wrote:

I think the world of PC emulation just has an attitude problem. They don't know how to build proper emulators, and they don't know that they don't know how to build proper emulators.

Scali wrote:

It is simply inexcusable that for the most popular personal/home computer platform out there, nobody seems to be capable of delivering a proper emulator. The C64/Amiga people apparently have much higher standards/skills.

Ok, Scali, that is it, challenge accepted! 😀

I am going to fork my emulator code, and have it just emulate the IBM PC. No PCJr, 186, 286, 386, AdLib, etc. Just the IBM PC. My code already emulates the bus , the prefetch queue (on bus idle cycles), memory wait states, CGA memory vs conventional ram speed, 8bit bus, instruction cycle timing (including accurate EA calculation timing). There are still quite a few things which I do not do at the moment, and lack support for (like CGA per pixel timing emulation and better instruction timing). I will work on fixing those.

So here it is. I finally did it. You can check more details at https://sites.google.com/site/capex86/home. It supports almost all SW/games I threw at it that should run on an IBM PC XT.

Basically this is an x86/x88 emulator that at the core is not an instruction emulator but rather a cycle emulator. Notice I am not saying mine is better just different. That means there is no such thing as the traditional loop:

1) fetch instruction (from prefetch or otherwise)
2) big switch statement (or function pointer table) to execute said instruction (and write out to memory or registers)
3) increment CS:IP
4) delay enough cycle to make it timing accurate
5) go to 1

Instead at the processor level it emulates the BIU and the EU (and EA) at the cycle level and it will do required action each cycle same as a real processor does. In other words only the work required for that cycle for a given instruction is done in a given cycle (now that is not true for the actual execution say a-b, as that I do instant when execution needs to happen but no results are written out of course until it is time). Also things like HW interrupts or NMI are also emulated in the cycle fashion which is not something I've ever seen done.

A little bit of its log explains a bit more:

Cycle 4654501 T1                          [ 0xb4 xxxx xxxx xxxx ]    EA calculation   {  ea  read  execute  delay  } 
Cycle 4654502 T2 [ 0xb4 xxxx xxxx xxxx ] EA calculation { ea read execute delay }
Cycle 4654503 T3 [ 0xb4 xxxx xxxx xxxx ] EA calculation { ea read execute delay }
Cycle 4654504 T4 0xff675 0x a >P [ 0xb4 0x0a xxxx xxxx ] EA calculation { ea read execute delay }
Cycle 4654505 T1 [ 0xb4 0x0a xxxx xxxx ] EA calculation { ea read execute delay }
Cycle 4654506 T2 [ 0xb4 0x0a xxxx xxxx ] EA calculation { ea read execute delay }
Cycle 4654507 T3 [ 0xb4 0x0a xxxx xxxx ] { read execute delay }
Cycle 4654508 T4 0x003e2 0x 7 <M [ 0xb4 0x0a xxxx xxxx ] { execute delay }
Cycle 4654509 T1 [ 0xb4 0x0a xxxx xxxx ] executing { delay }
Cycle 4654510 T2 [ 0xb4 0x0a xxxx xxxx ] { decode }
Cycle 4654511 T3 <P [ 0x0a xxxx xxxx xxxx ] new opcode 0xb4 { imm execute delay }
Cycle 4654512 T4 0xff676 0xb9 <P >P [ 0xb9 xxxx xxxx xxxx ] { execute delay }
Cycle 4654513 T1 [ 0xb9 xxxx xxxx xxxx ] executing { delay }
Cycle 4654514 T2 [ 0xb9 xxxx xxxx xxxx ] executing delay { decode }
Cycle 4654515 T3 <P [ xxxx xxxx xxxx xxxx ] new opcode 0xb9 { imm execute delay }
Cycle 4654516 T4 0xff677 0x 1 >P [ 0x01 xxxx xxxx xxxx ] waiting for data { imm execute delay }
Cycle 4654517 T1 <P [ xxxx xxxx xxxx xxxx ] waiting for data { imm execute delay }
Cycle 4654518 T2 [ xxxx xxxx xxxx xxxx ] waiting for data { imm execute delay }
Cycle 4654519 T3 [ xxxx xxxx xxxx xxxx ] waiting for data { imm execute delay }
Cycle 4654520 T4 0xff678 0x 0 >P [ 0x00 xxxx xxxx xxxx ] waiting for data { imm execute delay }
Cycle 4654521 T1 <P [ xxxx xxxx xxxx xxxx ] { execute delay }
Cycle 4654522 T2 [ xxxx xxxx xxxx xxxx ] executing { delay }

Format is
cycle number / cycle type / memory address / memory data / data action (>P read into prefetch, >M write to memory,etc) / prefetch buffer contents / CPU state / next CPU stages

It is written in a nice and clean C++ with a very good inheritance hierarchy so that I can build processors by putting together a certain class of BIU and certain class of EU (or EA).

There is a lot more information on the website about features that I will not mention here.

I just want to say thank you to all who helped me and without him I could not have done this (in no particular order): Jepael, reenigne, superfury, Scali, gdjacobs and all others (you know who you are).

But all this does not really matter because what I really want to do is have 8088MPH running perfectly which it is not 🙁. There are still some visual issues due to a) some cycle timings not being 100% accurate and b) my CGA emulation still not being 100% there in terms of timing.

I am trying to figure out how to push my code on github and not upset my employer. So for now, if anyone would like to see the code, just drop me a note as a personal message and I will provide it to you.

Enjoy the cycles!

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 2 of 30, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

First binary release (for Windows) available on the website. Source code should be available from here: https://bitbucket.org/vstamate/cape-public,

Because this is a cycle emulator and not an instruction emulator (and because I have not spent that much time optimizing it) it is somewhat slower than normal emulators so on my PC (Core i7 4790 @ 3.6Mhz) it only goes up to 8088 @ 16Mhz. Higher than that it cannot run at 100% speed. Which means I am spending about 750 Core i7 clocks to emulate 1 8088 clock (and the CGA and everything else on the machine). Not that good, I know but I will be improving that.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 4 of 30, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

Dammit. Sorry about that. I am using Windows 10 here. Let me see if I can grab a Windows 7. Might be related to Visual Studio runtime stuff.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 5 of 30, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

Did you run it by itself or did you pass any parameters? If you chose not to use the GUI, try running with "CAPE.exe configs/xt-cga.cfg" from command prompt.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 6 of 30, by NewRisingSun

User metadata
Rank Oldbie
Rank
Oldbie

The GUI runs well, and I have indeed run the emulator with the correct command line. But I think the message appears before the program even has a chance to look at the command line. I can run Dependency Walker if you should find it useful.

Edit: Here's what Dependency Walker says:

  • Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.. "error opening file the system cannot find the file specified" on:
    • API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
    • API-MS-WIN-CORE-WINRT-L1-1-0.DLL
    • API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
    • API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
    • DCOMP.DLL
    • IESHIMS.DLL
  • Error: Modules with different CPU types were found.

Of course, judging by the comments in various forums around the net, Dependency Walker's error messages seem to be caused by the program tripping over its own feet half of the time, so maybe these messages are entirely off-base.

Reply 7 of 30, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

Ok so the actual problem is that when you build apps using Visual Studio 2015 the VC2015 Redistributable package is needed to run those apps. I need to figure out how I can make that not happen. In the meanwhile Microsoft offers the download here: https://www.microsoft.com/en-us/download/deta … s.aspx?id=48145

Sorry for the problems. I might include the require DLLs in the binary package itself.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 8 of 30, by spiroyster

User metadata
Rank Oldbie
Rank
Oldbie
vladstamate wrote:

Ok so the actual problem is that when you build apps using Visual Studio 2015 the VC2015 Redistributable package is needed to run those apps. I need to figure out how I can make that not happen. In the meanwhile Microsoft offers the download here: https://www.microsoft.com/en-us/download/deta … s.aspx?id=48145

Sorry for the problems. I might include the require DLLs in the binary package itself.

Is the result a single .exe? If you don't spread out the code over dll's you can use /MT flag to statically link the runtime libs into the single exe (Ergo no requirement for the redist dll's) Otherwise you need to build with VS6.0.

You are fully allowed to ship those runtime dll's in your installer and redistribute.

[EDIT:] I think you can build anyway with /MT if your compiling dlls for the same program, its just the CRT will be duplicated (statically linked in each dll) and I'm not too sure how this would behave at runtime o.0

Reply 9 of 30, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

Thank you Spiroyster. I have now recompiled with /MT and verified that it works on a separate Windows10 machine which did not have any Visual Studio installed.

I have fixed a few other issues too (and added some features). More information in the bugs.txt and release.txt. A version 0.2 is now available on the website.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 11 of 30, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie
danrevella wrote:

hi!
the link for downloadin ver 0.2 is wrong

Yes, you are right, sorry about that. I fixed it now.

danrevella wrote:

the link for the superbios go to the ver 3.0 who does not have a .bin ver

Indeed it does not. 2.6 and before do though. I made a note on the webpage for users to download 2.6.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 13 of 30, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie
danrevella wrote:
I may confirm: the game Zaxxon works 100% desqview will never work: an higher processor is requested copyiipc does not work (it […]
Show full quote

I may confirm:
the game Zaxxon works 100%
desqview will never work: an higher processor is requested
copyiipc does not work (it use both bios int 13+ direct port access)

Thank you for trying it. Desqview requires protected mode IIRC. I am about 70% done with adding 286 support which should enable applications like DesqView to run.

I will check copyiipc. It likely triggered some bug in my floppy disk controller implementation.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 14 of 30, by NewRisingSun

User metadata
Rank Oldbie
Rank
Oldbie

The emulator runs well now, but there was one disappointment for me: the PC speaker does not seem to be emulated at all when it is clicked manually, meaning that the program does not use Gate 2 but counts CPU cycles until it flip port 61 bit 2. I was hoping that the cycle-exact CPU emulation would get Ultima III's sound effects as intended and heard nothing. (I did hear sound from 8088 MPH, so it's not that I disabled sound or anything.)

Reply 15 of 30, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie
NewRisingSun wrote:

The emulator runs well now, but there was one disappointment for me: the PC speaker does not seem to be emulated at all when it is clicked manually, meaning that the program does not use Gate 2 but counts CPU cycles until it flip port 61 bit 2. I was hoping that the cycle-exact CPU emulation would get Ultima III's sound effects as intended and heard nothing. (I did hear sound from 8088 MPH, so it's not that I disabled sound or anything.)

I agree, I need to improve that. I am working on it.

Edit: I reproduced the lack of sound. I am working on a fix now.

Last edited by vladstamate on 2017-01-04, 19:22. Edited 1 time in total.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 17 of 30, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

I fixed the speaker issues in Ultima III. I actually ran it on my 386 first to see what I should expect. I am not actually getting 100% accurate, but good enough. I'll try some other games too.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 19 of 30, by spiroyster

User metadata
Rank Oldbie
Rank
Oldbie

I'm certainly looking forward to giving it look when I get some time, many thanks for the effort. This era hardware is all a big black box for me, have experience with it, but I would be lying if I said I knew what I was doing at the time. 😵