How Works the fifth fruit Yoshi Crash (NSMBW)

The Fifth Fruit Crash in New Super Mario Bros. Wii

The Fifth Fruit Crash in New Super Mario Bros. Wii

One of the most intriguing and lesser-known bugs in New Super Mario Bros. Wii occurs when Yoshi consumes the fifth fruit and is hit in the exact frame he attempts to lay an egg. This bug, caused by a typo in the game's code, results in a complete system freeze, accompanied by a looping audio fragment.

This document provides a technical analysis of the bug, its causes, and its implications across different game versions.


Bug Description

Conditions for Reproduction

To reproduce the crash, the following conditions must be met (as documented in community sources):

  1. In World 1-3, mount Yoshi and consume the fifth fruit (any of the fruits that activate Yoshi's floating ability).
  2. When the enemy is very close (like the Yoshi Crash Video), consume the fifth fruit.
  3. In the correct frame Yoshi attempts to lay an egg, hit an enemy (or take damage from any source).

Expected vs. Actual Behavior

Expected Behavior: After consuming the fifth fruit and taking damage, Yoshi should transition to his running animation.

Actual Behavior: The game freezes entirely. The screen remains static, and the audio loops indefinitely.

Root Cause: The bug is caused by a typo in the game's code. Yoshi's running animation state is named "Rrun", but the game attempts to transition him to a state called "run" (which does not exist). This mismatch causes the game to fail when trying to load the non-existent state, resulting in a crash.

This bug is present in the following versions of New Super Mario Bros. Wii:

  • North American (NTSC)
  • Japanese (NTSC)
  • European (PAL)

It was fixed in the Korean, Taiwanese/Hong Kong, and Nvidia Shield versions, which were released approximately one year later.


Technical Analysis

The Exception Handler

The Exception Handler is a development built-in tool used to identify errors in the game, such as memory faults or crashes. On the Wii console, which uses a PowerPC-based processor (IBM Broadway 729 MHz), the Exception Handler logs critical information, including:

  • The type of exception (e.g., invalid memory access).
  • The memory address where the error occurred.
  • The state of CPU registers at the time of the crash.

In the case of the Fifth Fruit crash, the Exception Handler would detect an error when attempting to access the invalid "run" state. However, since the game lacks robust error handling for this scenario, it results in a complete freeze.

Accessing the Exception Handler: After a crash occurs, you can display the Exception Handler screen by pressing the following button combination on the Wii Remote:

HOME, -, +, -, +, 1, 2, 1, 2, A

This screen provides detailed technical information about the error, which is useful for debugging.

Why the Game Freezes

When the Wii's CPU encounters an invalid instruction (such as loading a non-existent state), it stops processing the game. This causes:

  • Screen Freeze: The graphics engine and main controller halt, leaving the screen static.
  • Audio Loop: The Wii's audio chip (DSP) has its own internal memory buffer. When the CPU freezes, the DSP continues to play the last audio fragment it received, resulting in a looping sound.

The Audio Buffer and Loop

The Wii's audio chip uses a buffer to store the next few milliseconds of audio. When the CPU stops processing:

  1. The DSP does not receive new instructions to change or pause the music.
  2. The buffer continues to play the same fragment repeatedly at high speed, creating a buzzing or repeating sound effect.

This phenomenon is common in crashes on older consoles, where audio and video are handled by separate components.

Audio Loop Example

Example of the audio loop when the crash occurs:

The same thing happens with the Buffer, but it's not the same sound as the well-known Horn of Death, see: https://youtu.be/miIT-athguI


Code Analysis

The bug is rooted in a typo within the game's state management system. Below is a hypothetical representation of the affected code logic:

// Hypothetical code snippet based on disassembly
if (yoshiState == DAMAGE_STATE && input == LAY_EGG) {
    nextState = "run"; // Error: should be "Rrun" (the correct state name)
}
        

The game attempts to transition Yoshi to the "run" state, which does not exist. The correct state is "Rrun", so the game fails to proceed, leading to a crash.

State Management in NSMBW

New Super Mario Bros. Wii uses a state-based system to manage character animations and behaviors. Each state corresponds to a specific action (e.g., running, jumping, taking damage). The typo in the state name disrupts this system, causing the game to attempt an invalid transition.


Version Comparison

The bug was fixed in later versions of the game, specifically the Korean, Taiwanese/Hong Kong, and Nvidia Shield releases. These versions were released approximately one year after the original versions, suggesting that the typo was identified and corrected during development or localization testing.

The following table summarizes the affected and fixed versions:

Region Version Bug Status
North America NTSC Affected
Japan NTSC Affected
Europe PAL Affected
Korea NTSC Fixed
Taiwan/Hong Kong NTSC Fixed
Nvidia Shield Custom Fixed

Reproduction and Testing

Steps to Reproduce

To reproduce the bug, follow these steps:

  1. Start World 1-3 with Yoshi.
  2. Consume four fruits normally, When the enemy is very close (Like the Yoshi Crash Video) then consume the fifth fruit (the one that activates Yoshi's floating ability).
  3. In the correct frame Yoshi attempts to lay an egg, ensure he hits an enemy or takes damage.

Result: The game will freeze, with the screen static and the audio looping.

Testing in Dolphin Emulator

The Dolphin emulator provides tools to analyze the crash in detail:

  • Memory Viewer: Observe changes in memory addresses related to Yoshi's state when the crash occurs.
  • Frame Advance: Use this feature to step through the game frame by frame and pinpoint the exact moment of the crash.
  • Exception Logs: Dolphin can log exceptions, providing insight into the error's nature.

Implications and Lessons

The Fifth Fruit crash highlights several important aspects of game development:

  • Code Consistency: Typos in state names or other identifiers can lead to critical errors. Using linters and automated testing can help catch such mistakes.
  • Error Handling: Robust error handling mechanisms can prevent crashes when invalid states or inputs are encountered.
  • Testing: Thorough testing, including edge cases like correct frame inputs, is essential to identify and fix bugs before release.

This bug also demonstrates the importance of version control and patching. The fact that later versions of the game fixed the issue suggests that Nintendo identified and addressed the typo during development or localization.


References

  • Demonstration of the Fifth Fruit Crash (YouTube).
  • Information about the Horn of Death (Reddit).
  • Community source: "In World 1-3, you have to eat the fifth fruit and hit an enemy on the same frame. Yoshi is programmed to switch to an animation called 'run', which doesn't exist (Yoshi's running animation is called 'Rrun'), so the game crashes."
  • TASVideos and Glitch City community forums for technical discussions on New Super Mario Bros. Wii bugs.
  • Wii SDK and development documentation for technical details on the console's exception handling.

No hay comentarios:

Publicar un comentario

NUEVO FOROOOOO

AQUI PUEDEN COMPARTIR CUALQUIER COSA  AHORA YA Y REGISTRATE Y ONLINE