The title menu before and after the fix. Quite hard on the eye before the fix.
Now all three work. The game wasn't rebuilt, since there's no source to rebuild from. It's the original program with three kinds of patch, plus one small new DLL. As usual, Claude (Anthropic's AI) did the digging and the writing. I built the DLL on my Windows 2000 VM, ran the game on the phone and reported back.
The colours
Rayman doesn't use the phone's graphics system. It asks the kernel where screen memory is and writes pixels straight into it. That's why it's fast, and also why it broke.
The 9210's screen has 4096 colours: 4 bits each of red, green and blue in a 16-bit word. The 9500's has 65536: 5 bits of red, 6 of green and 5 of blue. Rayman's graphics are stored in the 9500's format already, and the game converts every pixel to the 9210's format as it draws it. On the 9500 that conversion scrambles the colours.
The title screen before and after.
The disassembly showed ten drawing loops, all with the same eight instructions doing the conversion. The patch replaces those eight with a plain copy of the pixel, padded to the same length, so nothing else in the program moves. The patcher finds the loops by their pattern, so it works on any copy of the game, and then fixes the code checksum in the program header. The first test on the phone: "Colors look good!"
The start of the first level, before and after. Red ended up in the green bits and green in the blue.
The sound
Rayman plays sound by talking directly to the 9210's Media Server, through four functions in its client library. The 9500 has a completely different sound system. It keeps the old library for compatibility, but the functions just return "not supported". So Rayman was silent.
The fix is a stand-in: RAYMANAUDIO.DLL exports the same four functions at the same positions and plays the sound through the 9500's own audio stream. The patcher renames the library in Rayman's import table. The new name is exactly as long as the old one, so the file layout doesn't change. To write the DLL, Claude first had to work out from the disassembly what Rayman actually sends: the settings, the volume, start and stop, a status request, and buffers of sound.
It took three tries:
- A panic. The first version died at once with E32USER-CBase 69. Rayman makes the calls from its own sound thread, which has none of the machinery Symbian's audio classes need. So the DLL now starts its own audio thread, and the exported functions only drop samples into a shared ring buffer.
- A screech. The second version made sound, but high-pitched and garbled. A log on the phone showed the rate and the timing were right, so the data had to be wrong. Back in the disassembly, the mixer's flags said 16-bit samples, not 8-bit. The DLL had read every byte as a sample, twice as many as there were. The game also counts the played sound in bytes, not samples.
- It works. Music and effects, at the right pitch. "It works!!!"
One more detail: Rayman decides how far ahead to mix by asking how much has been played. The 9500's audio stream says a buffer is done as soon as it has copied it, long before it's heard. Trusting that let the game race ahead. So the DLL counts played sound by the clock instead.
The rocker
The arrow keys worked, but the 9500's rocker, the little joystick by the screen, didn't. Rayman looks keys up by their scan code, the hardware code of the key, and on the 9210 there was no rocker to look up.
The 9500's scan codes for the rocker weren't anywhere I could find, so Claude wrote a tiny app, KeyTest, that shows the raw code of every key press. The rocker turned out to send its own scan codes, while passing the ordinary arrow keys on as key codes. That's why most apps work with it and Rayman, which reads scan codes, didn't.
Rayman keeps two binding tables, eight bytes each: the arrow keys and some letters, then alternates. The patch writes the rocker's codes over the alternates for the four directions, and the middle press over Enter's. Result on the phone: "It works!!!!!!!!!"
Just for me
This one stays on my own phone. Rayman was made by a lot of people who didn't ask for their game to be patched, so I'm not sharing the patched game, the patcher or the DLL. This post is only the story of how it was done.
Rayman was made for one Communicator, and with three small patches it runs on the next one, colours, sound and rocker included.








Ei kommentteja:
Lähetä kommentti