Shenmue (1999) reverse engineering reveals possible sun position oversight

wulinshu.com

183 points by BafS 11 days ago


bbayles - 11 days ago

Fantastic game!

The same development studio, Sega AM2, recently had a developer reveal that he had put an Easter egg into Fighters Megamix for Saturn. However, he mistakenly introduced a crash bug in it.

This set me off looking for the Easter egg. After a couple days of reverse engineering, I finally found it [0]! I love looking for this stuff.

[0] https://32bits.substack.com/p/bonus-fighters-megamix

chiffre01 - 11 days ago

Playing through Shenmue 1, they did a really good job capturing the vibe of the area. Looking at random points in Yokosuka just feel like Shenmue.

https://www.google.com/maps/@35.2781594,139.677597,3a,75y,27...

AdmiralAsshat - 11 days ago

Reminds me of a similar story about Blast Corps, specifically how they implemented logic to correctly display apparent retrograde motion vis-a-vis the orbit of Venus from the perspective of Earth...all just for what basically amounts to a background animation. [0]

[0] https://www.youtube.com/watch?v=FZ6eNJi02Qk

TapamN - 11 days ago

Shenmue is one of my favorite games. I did a bunch of Ghidra reversing on the Dreamcast version last year, since I wanted to add improvements to it. Like adding bilinear filtering on the sky background, making time run a bit (faster so you can see time specific events like Christmas/New Year more easily,) getting the game to run without disc swapping on an ODE, and adding antialiasing (which would require mipmaps to improve rendering performance, which would require higher texture compression levels to get them to fit, which would require a different texture format that supports that...) I never got around to actually implementing any of that, outside of doing some experiments, like forcing bilinear on all 2D elements.

I don't think I found the sun/moon code (or more likely I did, but didn't realize what exactly it was doing, Ghidra SH4 has serious problems with floating point instructions making following anything that uses them almost impossible) but I did find most of the other time related code for updating the clock/calendar.

One weird thing I found while doing that is about the in-game watch. You always have a watch in your inventory, so you'd think it would be hard coded in, but it's treated like any other item. The game also has code to check if the watch is missing and add it back in anyways. But the code that draws the on-screen clock also checks if you don't have the watch, and won't draw the clock if you don't have it (or at least part of the UI clock logic is disabled, I haven't actually tried seeing what happens if you don't have a watch to verify if my interpretation is correct).

On the PAL version, the code that checks for a missing watch is at 0x0c180dc6 (that's where the code is loaded into memory, subtract 0xc010000 to get the address in 1ST_READ.BIN), and I think the code for drawing the clock (or at maybe it was just updating the hands of the clock?) is at 0x0c18290a.

Dreamcast Shenmue has code to support other video modes, like alternate resolutions (320x240p!), antialiasing, and 24/32 bit color. They're a bit bugged, like when using antialiasing, the 2D elements being squashed into the left half of the screen, and some strange issue with the screen position for the RAMDAC being setting incorrectly, causing the screen to vibrate left/right by a pixel or two, but the 3D models were drawn correctly.

24-bit color worked surprisingly well (even if the flag intended to enable it didn't seem to work, and I had to force it elsewhere.) I would have thought that having less video RAM free would have caused serious problems, but the game just loaded fewer NPCs. It was strange playing without dithering.

Ros2 - 10 days ago

The moon in-game also has a complex implementation. I don't think anyone realized this until the team porting the games to modern consoles pointed it out in an interview

https://www.phantomriverstone.com/2020/09/ryo-goes-to-moon-s...

regus - 10 days ago

I was really hyped for Shenmue when it came out on the Dreamcast, but I wasn't crazy about it once I finally played it. It was a glorified point and click adventure game, and it ultimately had no ending or purpose. It was an interesting and ambitious idea for a game though, they threw the kitchen sink in there.

My favorite part of the game was playing space harrier in the arcade.

mtillman - 10 days ago

I read every piece of US magazine coverage during the development of this game until finally 3-4 years later I bought my Dreamcast on launch and eventually Shenmue followed by a boot disc and Shenmue 2 (UK). 6 years of waiting to spend countless hours playing Space Harrier and Pachinko not to mention find some sailors. Absolutely loved this game.

ghostly_s - 10 days ago

I’m not sure a single person in this thread actually read the article rather than just taking an opportunity to say how much they like the game.

I read it and I’m not sure I get the point—it seems in the end what they discovered is the simulated sun position in the first two games are based on each other's locations. Not familiar enough with the series to understand what implication that has, but in any case, is it an easter egg or an oversight? It can't be both.

nanna - 10 days ago

Shenmue I and II will stay with me forever. I waited and waited for Shenmue III, and swore that when it came out I would buy whatever it took to play it, but the reviews were so poor that I haven't even tried it. Is it worth it?

khaki54 - 9 days ago

Imagine being proud of yourself for 25 years, displaying "implemented innovative orbital positioning methodology for Shenmue" on your resume. It was even your promotion case for staff engineer since you did it yourself, and some guy comes by more than 2 decades later and points out that you actually did it wrong

pkdpic - 10 days ago

I just coincidentally found my old dreamcast while cleaning out my dad's storage space... Guess I'll be buying some batteries for my VMU...

Also excellent write up and discovery, truly inspiring *clap_emoji *bow_emoji

qingcharles - 10 days ago

My all-time favorite game. What's the best version to play these days?

bitbasher - 11 days ago

Ok, but do they know who Lan Di is?

NooneAtAll3 - 11 days ago

I wish the article spent 2 sentences introducing wtf Shenmue is

tt_dev - 10 days ago

Didn't read the article but man do I love this game.

yoyohello13 - 11 days ago

Man I loved this game so much as a kid. I remember being enthralled by opening the drawers, lol. I basically played it once a year every year from ages 9 - 16. Some of the enchantment was lost when I played the remaster recently, but still such a great world they built.

wk_end - 11 days ago

The tl;dr (though you should read!) of the "oversight" is that there's a constant used to adjust the sun's position that's seemingly based on latitude; in the first Shenmue, it's set to 22, and in Shenmue II - which uses much of the same code - it's set to 35. This is odd, because Shenmue I takes place at latitude 35°, and Shenmue II at 22° - precisely the other way around.

If that's what's going on, it's sort of hard for me to wrap my brain around how that might've happened. I could see them "fixing" the Shenmue I code base and then forgetting to "unfix" it for Shenmue II, but I can't - even knowing that there were already plans for where the sequel would be set - come up with a story for how they would've accidentally used Shenmue II's latitude for the original game.

kowlo - 11 days ago

What a game. Lost hours to QTE Title (one of the games within the game) https://www.youtube.com/watch?v=drdFhBKDvIQ