Is it, in theory, possible to make, eg Atari 2600 (or NES, or Sega) emulator from QEMU?
Is it, in theory, possible to make, eg Atari 2600 (or NES, or Sega) emulator from QEMU?
QEMU is a great project, but to begin with flexibility was not a primary design goal. Majority of QEMU targets are PC-like hardware and older consoles have unique or alien architecture. To emulate it using QEMU you'll have to patch it internals heavily. It's also written in C so you can't just integrate a lot of fancy libraries into it.
QEMU is also important infrastructure project playing crucial part in *nix virtualization stack. Which means getting any code upstreamed is hard. Emulation projects primary goal is to make games run both accurately and as fast as possible which means developers will use as many shortcuts as possible.
QEMU is a massive code base too. Getting into it will take a lot of time and it could be easier to maintain single-target emulator instead since it's easier for new contributors to start working on it. You'll have to fork QEMU anyway and won't be able to push your changes upstream then what the point to use it?
And the PS4 uses a custom AMD x86-64 chip.
An Xbox 360 is slightly more difficult as that is a PowerPC architecture (RISC vs. CISC of x86) Same for the PS3 except you also have those incredibly weird "SPE" cores to try and emulate as well.
Of course if your goal is to just have games from OG Xbox playable on a PC that is fine (if anything for most games it is an improvement as they'd run smoother) but if you want cycle accurate emulation it doesn't fit the bill. In that case basing the emulator on something like 86box might be better as that has been designed with the goal of achieving cycle accurate PC hardware emulation.
Qemu takes a higher level approach that basically guarantees that over a period of time, one tick of the CPU corresponds to X ticks of the GPU on average and does expose a fair amount of host memory performance characteristics such as TLB/L1/L2 cache misses. PS2 games weren’t built to account for pipeline flushes or memory stalls, for example.
I still find it so funny that they figured the best way to run the GPU was to have 2560 bit wide data bus on 4MB of RAM. So you could go fill rate crazy but on a very limited data set.