EmuDevz: A game about developing emulators
https://afska.github.io/emudevz/
#HackerNews #EmuDevz #Emulator #Game #Development #Gaming #Community #EmulatorDevelopment
EmuDevz: A game about developing emulators
https://afska.github.io/emudevz/
#HackerNews #EmuDevz #Emulator #Game #Development #Gaming #Community #EmulatorDevelopment
And this is why a Game Gear emulator must also be able to emulate the SMS. Or at least run a the scaled version of Master System game, also called "SMS mode".
The differences are minimal though, since the Game Gear is basically a portable Master System, but with a smaller screen resolution, more colors and stereo support. Some Master System versions do have a different sound chip though, to allow richer sound.
Got back into my Atari 2600 emulator again last week. In fixing one problem with the RSYNC register, I seem to have re-broken something else that Iโd I fixed previously ๐ฐ
Anyway. Next week Iโll get into the audio emulation. I had a go at it sometime last year, but struggled to getโฆ anything ๐ I was trying to rush it though.
Thanks to Calindro, the author of Emulicious, a very powerful emulator and debugger, it made everything much simpler when writing this romhack!
Just had a quite interesting bug hunting experience.
Since rust 1.78 broke my gears emulator, I added testing with the nightly toolchain to the (github) CI. And since it was easy, I also added more platforms: macos and windows. The first worked flawlessly (and brought arm64 testing). But on windows, building failed because of a library and binary that had the same name in the workspace. That was an easy fix; but then a test was failing.
I went looking at the code, and it was incredibly ugly. For my defence, I wrote this test code 3 years ago in a hurry, but it did not help the debugging. The failing part was during parsing, so I suspected some difference of behaviour of the code on Windows vs Unix. But having a quick look, it did seem quite portable.
The string parsing arrived at a different result, so I suspected the rust include_str! macro;โฏbut the doc did not document any difference of behaviour. Was it a doc bug? Or the github actions environment that mangled the files? I wrote a quick hexdump, and found that the file on disk was the same as the one in memory: include_str! was not to blame. But was it github's fault?
Looking at the raw logs, the checkout github action called git.exe with no weird argument, and ran no command that would mangle the files.
So I had a look into git's own documentation, and bingo:
https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_autocrlf
By default on GitHub's windows runner, git will auto-detect text files, and convert the line endings to the platform-native versions. But I didn't want it to do that! And I'm not alone:
https://github.com/search?q=repo%3Aactions%2Fcheckout+autocrlf&type=issues
Luckily, you can use git attributes to tell git to not treat some files as text, and it won't do the conversion:
https://git-scm.com/docs/gitattributes#_text
and this is exactly what I did:
https://github.com/anisse/gears/pull/5/commits/36037115ca93dba50a45e4fd0b07f9165b66af39
My FOSDEM 2024 Emulator ๐พ talk "How do you write an emulator anyway ?" is now available !
You'll find video and slides directly on the talk page: https://fosdem.org/2024/schedule/event/fosdem-2024-2146-how-do-you-write-an-emulator-anyway-/
I'll be heading to FOSDEM tomorrow evening ๐ฅณ ! I'll be giving two ( ๐ฑ ) presentations for this edition ! Come and say hi ๐
"WASM 101: porting a Sega Game Gear emulator to the browser" on Saturday at 15:30 in the Rust ๐ฆ devroom https://fosdem.org/2024/schedule/event/fosdem-2024-1691-wasm-101-porting-a-sega-game-gear-emulator-to-the-browser/
and
"How do you write an emulator anyway ?" on Sunday at 9:00 in the Emulator ๐พ โ devroom https://fosdem.org/2024/schedule/event/fosdem-2024-2146-how-do-you-write-an-emulator-anyway-/
Good news: I'll be presenting a talk at FOSDEM ๐
Stressful news: I'll be presenting two talks at FOSDEM ๐ง
WASM 101 in the Rust devroom https://fosdem.org/2024/schedule/event/fosdem-2024-1691-wasm-101-porting-a-sega-game-gear-emulator-to-the-browser/
Howto in the Emulator devroom https://fosdem.org/2024/schedule/event/fosdem-2024-2146-how-do-you-write-an-emulator-anyway-/
See you there !
Yesterday evening I was looking for documentation on emulators, and I found this phrase:
> The Z80 CPU has [โฆ] "fetch/execute overlapping"
With a diagram showing overlapping machine cycles: http://www.z80.info/z80arki.htm
I went into a mild panic. Did I really miss that information in my emulator ?โฏThis changes cycle accuracy by a big (~1/3) factor, which would impact both display and sound generation.
So I shared this on the smspower discord, and went digging. After a few exchanges, it was obvious, that while this assertion is true (it has fetch/overlap execution), it's also useless when compared to the machine cycles documented in the Z80 CPU User Manual: they already take this into account !
What happens is that if an instructions has remaining work that is purely ALU, and takes at most one M cycle, the documentation will "hide" this remaining work since it will happen during the next instruction fetch. This is how many single-byte 8-bit arithmetic instructions can take only one machine cycle (4 t-states), while this machine cycle should be just for the memory fetch of the instruction.
The Z80 has been fully reverse engineered at the logic level, and there is an online simulator:โฏhttps://floooh.github.io/visualz80remix/ ; so I did a simple test with those two instructions:
AF XOR A
80 ADD A, B
(clear the memory area with 0s, and write AFโฏ80 in it)
In both cases, we can see that the A register isn't updated until we are in the first machine cycle of the next instruction! And it doesn't matter since this M cycle is used for memory fetching, so there won't be any observable side effect at the software level.
In the end, my #gears emulator has correct timings, and I'll have to find another excuse for why the PSG sounds so bad ๐
So, tell me what you think (boost appreciated) about #emulator development.