Wednesday, October 27, 2010

CD-i Emulator Cookbook

Just a quick note that work on CD-i Emulator hasn't stopped.

I have some wild ideas about ROM-less emulation; this would basically mean re-implementing the CD-RTOS operating system. Somewhat daunting; it contains over 350 separate explicit APIs and callable entry points and many system data structures would need to be closely emulated. But it can be done, CD-ice proved it (although it took a number of shortcuts that I want to avoid).

I'm not going to tackle that by myself; my current thinking is to make a start by implementing a high-level emulation framework, tracing stubs for all the calls (luckily these can mostly be generated automatically from the digital Green Book and OS-9 manuals) and some scaffolding and samples.

One of the pieces of scaffolding would be a really simple CD-i player shell; one that just shows a big "Play CD-i" button and then starts the CD-i title :-)

For samples I'm thinking about a few easy system calls like F$CRC, F$SetCRC, F$SetSys, F$CmpNam, F$PrsNam, F$ID, F$SUser, F$Icpt, F$SigMask, F$STrap, F$Trans, F$Move, F$SSvc (I may not get through the entire list) and a new NVRAM File Manager (NRF).

It would be nice to do a minimal UCM with Video and Pointer driver so that the simple CD-i player shell would run, but that might be too much. We'll see.

However, it's the new NRF that would be the most immediately interesting for CD-i Emulator users. It would intercept NVRAM access at the file level and redirect it to the PC file system (probably to files in the the nvr directory). This would allow easy sharing of CD-i NVRAM files (e.g. game-saves) over player types or between CD-i emulator users.

To allow all of the above and clean up some dirty tricks that were needed for input playback and handling Quizard, I've done some internal restructuring of CD-i Emulator. In particular, I introduced a new "handler" class beneath the existing "device" and "memory" classes (which are now no longer derived from each other but from a common "component" base class). This restructuring isn't finished yet, but it will allow the input and Quizard stuff to become handlers instead of devices (the latter is improper because they shouldn't be visible on the CD-i system bus).

The new "module" class (a subclass of handler) will be used to add high-level emulation of OS-9 and CD-RTOS rom modules. I want to preserve the interfaces between the modules and the public data structures as much as possible, because it will allow a gradual transition from "real" to "emulated" modules.

To prepare for all of the above I had to do some fairly heavy design, which caused me to properly write down some of the design information and tradeoffs for the first time. This will be invaluable information for co-developers (if they ever materialize), hence the title "CD-i Emulator Cookbook". Well, at present it's more like a leaflet but I hope to expand it over time and also add some history.

Pieces of the cookbook will be added to the CD-i Emulator website if I feel they're ready.

I've also been giving some thought on a collaboration model for the ROM-less emulation. If there is interest I could do a partial source release that would allow other developers to work on the ROM-less emulation. This release would *not* contain any non-video chipset emulation but it would contain "generic" CD-i audio and video decoding. You would still need to use (part of) a system ROM (in particular the OS-9 kernel and file managers) until enough of the emulation is finished.

I'm still considering all this, but I wanted to get the word out to see if there is interest and to show that I haven't abandoned the project.

Potential co-developers should start boning up on OS-9 and CD-RTOS. All of the technical OS-9 documentation is online at ICDIA and links to the digital Green Book can also be found.

Tuesday, October 12, 2010

Release blues and Quizard 1.7

Saturday I released CD-i Emulator 0.5.3-beta1. That was a big milestone for me.

The Internet didn't seem to feel that way. There was some interest but it was nothing compared to five years ago when the first version came out. Oh well...

Sunday a "disc activity" indicator was suggested by a MESS tester. It seemed cool so I added it by coloring the background of the "disc activity" textbox:

blue = reading TOC data
red = reading CD-audio data (mode 0)
yellow = reading CD-ROM data (mode 1)
green = reading CD-i data (mode 2)

I also wrote a proof-of-concept compatibility report table page for the web site so that I could view the reports entered, so far by a single user only (except myself). It needs more work, I won't tell you the URL yet :-)

A few days ago the MESS CD-i programmer requested help in figuring out why the Quizard 1.7 game didn't work and I provided some serial port help. In the process we deduced that the 1993-vintage 68070 datasheets on the Internet all have some of the UART command bits wrong. But I found a few datasheets dated April 1991 which have it right (and so does my 68070 User Manual, luckily, which is dated November 1991). With this fixed in MESS, both emulators produced the same effect: some loading activity and then remaining at a black screen.

Now, Quizard is one of those rare CD-i titles that require external hardware, in this case the so-called "CD-i Jamma" board that interfaces a CD-i player to the industry-standard (at one time) arcade enclosure interface. Bas wrote about this board in his Interactive Dreams blog here and here.

Part of the external interface is a "security" option that causes the game not to run unless the proper hardware is present, and this is what was causing Quizard to remain at a black screen.

Although it is certainly possible in principle to emulate the external board, including its security features, I was in the midst of releasing CD-i Emulator so I let it go for some time.

But today Just Deserts/Harmony/MooglyGuy (the main MESS CD-i developer) posted details about how to "patch" Quizard to avoid the security check and he also posted sufficient details to allow emulation of the arcade case buttons. So I dove in...

It took me an hour or two to create a special "quizard" device for CD-i Emulator that patches Quizard as needed and connects to the serial port to give the CD-i title the communications that it wants. For now I simply intercept PC keyboard digits 0 to 9 and pass them to Quizard as "button" information.

It works alright: Quizard plays its leader and starts "attract" mode and I can even play a game!

The following movie shows only the leader, however:



Note also the green flashing disc activity indicator!

Sunday, October 10, 2010

CD-i Emulator 0.5.3-beta1 released!

I have just released the new version of CD-i Emulator. It has received very limited pre-beta testing, but that's what public betas are for.

I've changed relatively little since the prebeta1 version.

The most import change is the addition of the Help | Report menu option that contains a link to the new Report section of the website and will automatically fill in most of the information fields on that form when clicked.

Unfortunately, to make this work properly I had to touch most files in the sys directory to add correct player model, extension and digital video cartridge identification.

I've also added checksum reporting of DV cartridges, let's find out how complete my current collection is. These checksums will not (yet) trigger an "Unknown ROM" dialog if unknown, but they are posted with compatibility reports.

The -writepng option also had to be fixed to support macros in its filename, otherwise each video frame would overwrite the previous one! The macros that I've decided to support for now are $seq$, which produces a 6-digit sequence number and $time$ which produces the 6-digit frame time (mmssff).

The Release Notes have been modified to include these changes.

Use of the input recording/playback functions revealed a number of bugs; I've fixed those and also added more player information recording so that recorded input files contain enough information for compatibility reports (this isn't used yet).

Monday, October 4, 2010

Website updates, bugfixes, compatibility reports

Today I updated the CD-i Emulator website for the upcoming beta release and fixed some remaining bugs, mainly with input recording/playback.

I updated the Release Notes section, put up the hopefully final version of the Full Release Notes, added more screenshots and YouTube embeds and did some miscellaneous text edits. I also updated the CD-i Types section and added a download for it.

It was my intention to release tonight, but that didn't happen because the closed pre-beta testers aren't ready yet. I'll give it a few more days.

My next project will be updating the Title Support section of the website; I want to replace the static table with a much more dynamic one that can be expanded and sorted in various ways, based on a database of actual compatibility reports for specific CD-i player ROMs and CD-i titles that could be entered online.

I might even accept MESS CD-i compatibility reports to provide a basis for comparison. Users would also be able to "me too" on reports.

I would also like to add a "Report Compatibility" option to CD-i Emulator; that would allow automatic filling in of most of the report fields so that entering a compatibility report becomes pretty much a question of clicking only a "compatibility class" button and possibly entering some notes (fields like Reporter could be remembered on the reporter's PC using cookies). It should be easy to add the CD-i Emulator part of this; I might even do it for the current beta if the testers take long enough :-)

For crashes or decoding issues, it would also be useful to allow uploading of input recordings. Actually, uploading a "good recording" would be nice even for successful reports. I could even add an "autorecord" setting to CD-i Emulator to make recording easy; the performance hit should be minimal.

This would also allow "batch" uploading of compatibility reports at some later time; input recordings contain all of the necessary information except for the compatibility class and notes and these could easily be added with input annotations, which I was planning to add anyway.

Unfortunately, uploading a file cannot be automated easily from within CD-i Emulator: the user will have to manually browse for the file. Another way to handle this would be to automatically generate an e-mail compatibility report...

Saturday, October 2, 2010

Lucky Luke on YouTube

I have just posted a "proof of concept" demonstration of CD-i Emulator MPEG decoding on YouTube:



The Philips Media bumper animation is MPEG (audio and video) and so is the audio for the piano sequence. The in-game crash is due to an MPEG sound effect.

This is with a Gate Array MPEG AH01 cartridge (22ER9141 F1 AH01); as the cartridge types get newer the decoding starts working lesser and lesser. Later GMPEG cartridges will crash earlier in the gameplay, VMPEG and IMPEG will not play MPEG at all. This is simply because I haven't gotten around to fixing those things yet; there are still major bugs in the buffering of the MPEG data and while that remains unfixed there is no point.

The magenta border indicates "beta" quality; it is not that hard to display the proper color (black in this case), but this will remind everyone that it is a work in progress.

Many other DVC titles will play their Philips bumper but crash soon thereafter; some others won't even get that far. In some cases this is not even due to MPEG decoding issues but to various "other" reasons for crashing (The 7th Guest is a notorious example).

I have also put up a new draft of the upcoming version 0.5.3-beta1 Release Notes on the website.

Release Notes

I have just put up a first draft of the Release Notes for the upcoming version 0.5.3-beta1 on the CD-i Emulator website.

More info coming...

Friday, October 1, 2010

CD-i Emulator pre-beta released

I have just released the pre-beta version of CD-i Emulator to my beta test group.

This version is intended for quick tests; if nothing drastically happens, the final beta1 release will happen in a few days.

In the meantime, I will be writing release notes and updating the CD-i Emulator web site. The final release notes will appear in the Release Notes section of the web site.

I managed to finish the input recording/playback code and also fix a few minor bugs.

Bug reports, comments or suggestions about this version should be posted on the closed CD-i Emulator beta Testing Forum.