Tuesday, September 13, 2016

Then - and now...


Here are some quick news regarding my side projects, and it's not about Emux this time. As it turns out, I have been working on a video game for the past few weeks, leaving emulation aside for some time. And not any video game, a remake of one of the bests: Wonder Boy III: The Dragon's Trap! Wikipedia describes it as a "platforming and action-adventure video game developed by Westone, published by Sega and released for the Sega Master System in 1989". It's definitely one of childhood favorites which I certainly spent hours playing as a kid, and it is now about to get a modern revamp by development studio Lizardcube (published by DotEmu). Check out the trailer below:

The story of how I came to join the development team is pretty random: as I was looking for a UI toolkit, I came across ImGui, a "fast, portable, renderer agnostic and self-contained graphical user interface library for C++", which is when I noticed the author of the library was Omar Cornut, a name I was familiar with thanks to his work on MEKA. After looking around for his latest work, I realized he had created Lizardcube along with Ben Fiquet, a video game studio currently developing Wonder Boy: The Dragon's Trap. I reached out to Omar, mentioning similarities in my background along with my love for the game, and joined the team soon after. The experience so far has been very rewarding, and I'm grateful I was given the chance to work with a team of very passionate and talented people. Stay tuned for more announcements soon!

Wednesday, August 3, 2016

Round 1 - Fight!

It's been a while since my last update - I have since moved to Sydney, Australia, and have kept busy with PSX emulation in my limited free time.


The above image (rendered by the BIOS) is what I was stuck on for quite a while. Getting past this screen required a lot more efforts that what I hoped for, including redesigning my CD-ROM controller implementation almost entirely due to me not fully grasping some of the complex documentation. Quite a lot of fixes were brought in by executing/studying Amidog's CPU, GTE, and GPU tests (the latter still highlights significant errors). This hard work paid off as I can now reach and even play some games!


Crash Bandicoot and Spyro both show serious texturing issues. The original code I developed within the software renderer portion of the GPU does not handle texture V coordinates properly, impacting rasterization - I haven't spent time on fixing this yet, but it should be pretty straightforward.


Dino Crisis does not go further that the advisory screen seen above. This is due to LibCrypt, a copy protection scheme relying on erroneous sector position data stored within CD-ROM subchannels. I am currently *simulating* subchannel P, therefore preventing this game from successfully booting.


Street Fighter Alpha 3, being a 2D-only game, does not suffer the artefacts described earlier. Unfortunately, the DualShock controller implementation I have so far seems problematic as most titles seem to miss input strokes, making this game not comfortably playable yet.

I am now focusing on other aspects of the console such as the motion decoder (MDEC) at the moment. Another major task to come is the redesigning of part of my clock ticking system in order to improve overall performance - I simply cannot reach full speed at the moment without various hacks, and this led me to studying and thinking of potential techniques to fulfill this goal. A good candidate so far, which will be a challenge to implement in a generic way, is derived from the "timestamping" method described on NESDev's wiki here:
http://wiki.nesdev.com/w/index.php/Catch-up

This progress would not have been possible without the help of simias (running tests on the real console while working on his own emulator, rustation), as well as Ryphecha (mednafen author, who helped me decipher not-so-well documented features such as scanline rendering and whose source code was helpful to fix some of Amidog's tests). Stay tuned for more updates soon!

Monday, March 7, 2016

It's dangerous to go alone! Take this.


Well, it did not take much time to add support for MMC1 for the NES core. That means new classics can now be played by grabbing Emux' latest master branch, or by using the core online updater of RetroArch, as seen by the screenshots above demonstrating the original Legend of Zelda, Teenage Mutant Ninja Turtles, and Mega Man 3 running on Emux standalone under Linux.

Sunday, March 6, 2016

NES MMC3 support + PPU improvements


Just finished adding support for MMC3 in emux! MMC3 is a type of cart that was pretty popular at the time, with quite a few games relying on it, such as Double Dragon II and Super Mario Bros 3, as seen in the above screenshots (nes libretro core running through RetroArch on Windows).

One of the nice features of this mapper is its scanline counter functionality (and associated interrupt signalling). The NES PPU (picture processing unit) does not have the ability to count scanlines natively, which is typically helpful for video games to draw some kind of status bar. For instance, when rendering a level (which commonly scrolls horizontally or vertically), you may want to reset the scroll registers at a certain Y coordinate to display the player's score, number of lives, or coins. During each visible scanline, the PPU accesses memory within the cart for rendering the background and sprites. Both are physically located at different address ranges, therefore from the cart's perspective this means a chip could actually detect the switch from background to sprite rendering once per line and increment a counter when this happens, effectively giving a scanline counter (reset being done during VBLANK). This is what MMC3 brings to the table.

The work done for this mapper forced me to perform more testing related to PPU rendering. A few issues were fixed, and I added support for missing features such as "large" sprite rendering and background/sprite clipping. The NES core is definitely looking better now. My next goal is to implement MMC1 support and get more classics running!

Thursday, February 18, 2016

NES audio + other updates

PlayStation emulation is on-going. I can now render the PS logo using my WIP geometry transformation engine implementation - this also proves the very painful CD-ROM controller is semi-working. Games are not booting at the moment and I hope to get some nice updates in the next few months.

I took a short break to implement NES audio. It took me a while to get started on this task but it was always on my TODO list. Luckily, the previous work I had done regarding Game Boy audio really helped in order to get this controller implemented smoothly. The NES APU is composed of five distinct channels: two pulse (or square) channels, one triangle channel, one noise (pseudo-random) channel, and a so-called delta modulation channel (DMC). Super Mario Bros uses the first four, while Bomberman uses DMC for bomb explosion sound effects (thanks to the folks on #nesdev for pointing this out), so testing was pretty straight-forward.

On a side note, I also improved overall performance a tiny bit by changing my clock scheduler implementation, which also now allows for arbitrary clock rates (which beforehand were expected to have a joint least common multiple which was small enough). This means that the various supported machine clock rates are now consistent with their real specifications.

Next step is to continue work for the PlayStation, and maybe implement some more NES mappers on the side.

Sunday, December 20, 2015

PSX boot (no disc inserted)


Some nice progress happened over the weekend - I fixed some texture mapping issues in the current software rendering implementation which was causing some undesirable effects, and added support for semi-transparency and dithering. I also started implementing the CD-ROM controller, and after stubbing a couple of other memory accesses (timer and joypad-related), the BIOS menu seen above showed up correctly.

I quickly tested faking some more CD-ROM commands and make the BIOS believe that a licensed game was inserted - this should normally lead to the well-known PlayStation logo. The screen does show up, but without the 3D rendered logo due to the lack of GTE support at this moment. Hopefully, that should be my next update!

Sunday, December 13, 2015

PSX stuff!


After playing with 8-bit consoles for a while, it's now time for some real challenge! In the past few months, I started looking into the original Sony PlayStation. The main CPU emulation is probably close to completion (the instruction cache implementation fore sure gave me some trouble). The DMA controller and GPU are a work-in-progress, but the work achieved so far allows the BIOS to be displayed properly (as seen in the screenshot above, with Emux running through RetroArch on Windows 10).

Once I manage to get some basic CD-ROM emulation, I should be able to reach the BIOS code path responsible for rendering the PS logo - this will also require the GTE to be working somewhat correctly (the geometry transformation engine is a co-processor responsible for 3D transformations, separate from the GPU which only handles 2D rendering). Let's hope for the best!

Wednesday, August 19, 2015

Full Game Boy audio implementation + more libretro news

After wrapping up some SMS issues, I went back and implemented a bunch of missing Game Boy PAPU audio features. Channels are now properly emulated (squares, wave, and noise) along with length counter handling, volume envelope, and frequency sweep. Debugging some of these was tricky, but the result was worth it! This work has been integrated into master, and can be tested either standalone, or via libretro frontends.

Emux is now part of the libretro ecosystem (cloned at https://github.com/libretro/emux), and automatically built for multiple architectures and operating systems (so far Linux, Windows, and Android). RetroArch's core updater can automatically fetch the latest binaries of all supported machines, so it is definitely the easiest/best place to start if you want to test out this on-going project.

Saturday, August 8, 2015

Libretro news


I realized not so long ago that Emux had been cloned by the RetroArch/libretro team - they fixed a couple of libretro-specific issues which are now integrated on my end. I am now working jointly with them in order to support as many platforms as possible. Emux is also now part of their buildbot's nightly builds! So far, Linux, Windows, and OSX builds are working properly, and the next step is to include support for other targets such as Android and iOS. On a side note, the Sega Master System branch is now integrated into master!

Tuesday, August 4, 2015

SMS audio

This past weekend, I decided to switch priorities and spent some time working on SMS audio. As it turns out, implementing the SN76489 chip was not as difficult as what I originally imagined. The tone and noise channels seem to be working correctly, meaning that a bunch of games are now fully playable including sound! Last time I worked on audio (for the GB PAPU), I remember the overall experience being quite complex, but that was mainly due to the audio resampling algorithms which were developed from scratch (they are now part of the framework). Now is the time for cleanup and integration.

Tuesday, July 28, 2015

Master System WIP


It took some time, but here it is: Emux now supports quite a few Sega Master System games! At least in my work-in-progress branch, as not so much has been integrated into the master branch yet. The Z80 processor is quite different than the GB80 which I originally based my implementation on - it has more registers, more instructions (and different ones with the same opcodes, which was the cause of some nasty bugs I ran into), different interrupt modes, port access, etc. The VDP (video display processor) was on the other hand pretty straight-forward to develop compared to the NES PPU due to the fact that my current implementation is not fully cycle-accurate (information is pretty hard to gather to get it emulated at that level). Below are some screenshots of other games so far proven to run correctly (I didn't even know Mortal Kombat was back-ported to that system!):


A good amount of unofficial Z80 instructions are not properly emulated at this time and some are unfortunately used by some games. Code cleanup is next in line once I add support for those as well as fix a few timing issues leading to scanline interrupts occurring too early for some titles.

Wednesday, December 3, 2014

SMS test


After sticking to Nintendo for a while, I decided to start a Sega Master System emulator. The Game Boy CPU is similar to the Z80 processor found in the SMS, so I was luckily able to reuse some source code. After implementing part of the Video Display Processor, I finally got one test ROM up and running, as seen above. The mapper work should be much easier than the NES and I should hopefully have a few games running soon!

Monday, July 7, 2014

Emscripten



Emux can now be run inside your favorite browser! For those of you who don't know what Emscripten is about, it basically allows you to compile LLVM bitcode (which can be generated from C/C++ using clang) into JavaScript. In the past couple of weeks, I worked on adding Emscripten support into Emux and actually had to develop a few missing APIs (SDL, musl, pkg-config) which eventually made it into their master branch. Go check out their wiki available at the following link:

Saturday, April 19, 2014

More fun than a boot ROM

As you can see above, the Game Boy core is now running more than the DMG boot ROM! MBC1 and ROM mappers (which include a large number of games) are now properly running. More on this later!

Sunday, March 9, 2014

Libretro implementation



One of my "side-projects" is now paying off! First of all, a little introduction taken from libretro's official website: "RetroArch is an open-source project that makes use of a powerful development interface called Libretro. Libretro is an interface that allows you to make cross-platform applications that can use rich features such as OpenGL, cross-platform camera support, location support, and more in the future.". In the last month or so, I have been implementing a libretro core for Emux (a separate dynamic library is actually generated per machine), allowing Emux to be launched within RetroArch (and other frontends). One of the nice things about RetroArch is its capability to apply shaders on top of generated frames - as you can see in the above screenshot, Excite Bike is running in Emux's NES core with an added NTSC filter shader.

Saturday, March 8, 2014

NES sprites


Finally some good progress on the NES machine implementation! I spent the past few months working on other aspects of Emux, but decided to finally come back to adding sprite rendering to the NES PPU controller. Super Mario Bros (which uses mapper 0 - the only one supported at the moment) can now be played fully, with no artifact which I am aware of.

Sunday, November 17, 2013

Game Boy progress


After working on a NES machine implementation for a while, I decided to merge my older Game Boy emulator into Emux. The CPU, LCD controller, and basic mapper support are integrated. No game works yet, but the boot ROM runs fine!

Wednesday, May 1, 2013

Welcome!

Welcome to my blog! I am not much of a writer and only plan to keep this blog for updates regarding my programming projects. Most of the news on the front page will be related to Emux, a cross-platform multi-machine emulator project I have been working on. Hopefully I will announce a release soon!