for the international release of super
mario bros 2 nintendo elected to take
the japanese game doki doki panic and
turn it into a mario game
in addition to swapping some graphics
and music nintendo also elected to give
mario 2 a few minor enhancements
we are fortunate to have access to a
prototype from earlier in the conversion
process that gives us a glimpse into the
game's evolution
nintendo's extra enhancements would
certainly add to the polish of the final
game
but it seems like perhaps many of them
were a bit rushed
i'd like to take a the scenes look at
these enhancements point out a few of
the bugs and also just
have a bit of fun with some of the code
since this video is going to dive into
hexadecimal and code it will get a bit
technical
that said i think it shouldn't be too
difficult to follow
before we do that let me catch you up a
bit on that prototype i mentioned
if you are familiar with mario 2 you'll
no doubt notice that this prototype
mario is missing the white behind his
eyes
as a matter of fact the face of the
mario sprite looks quite a bit like the
super mario sprite from super mario bros
3.
the heads in these two screenshots seem
to match quite well
the final head for mario and mario 2
would of course end up looking like this
both prototype mario and retail release
mario made the first issue
of nintendo power if you look at the
pages for the game you'll find both the
prototype mario head and the retail
mario head in the screenshots
that's a nice bit of documented history
for this game that would seem to be
unintentional
mario 2 was released in america in
october of 1988.
mario 3 was released in japan that same
month it would make sense that there
would be sprite sharing between the two
during development
there are a couple of musical
differences between the prototype and
the retail release
one example is that the music that plays
when you get the star
lacks some of the extra percussion that
was added a bit later
[Music]
a second and perhaps more noteworthy
difference is the underground theme
the retail release would end up sounding
similar to the doki doki panic version
[Music]
however in the prototype it sounds very
similar to mario 3's arrangement of the
original
underground theme
speaking of music let's dive into the
retail version and have some fun
the primary game mechanic of mario 2 is
the ability to pull items out of the
ground and throw them at enemies
one item that can be extracted as a
potion that allows you to enter
subspace through a red door the grass
tufts in this area yield
coins and you may also find a mushroom
that increases your maximum health
a few seconds of the original super
mario brothers theme can be heard during
the brief
time you are allowed inside
[Music]
that time and subspace is maybe 6
seconds
we know there is more to the original
mario 1 theme than the few bars that we
hear
during those seconds is more of the
mario 1 tune present in mario 2.
i'm going to use the debugger features
of the emulator fceux to investigate
this music question has been asked and
answered before
but we are more interested in the
investigation itself
more than the final answer on the left
side of the screen is a map of the nes
ram it is used to store various values
as mario 2 performs its tasks
ram is a great thing to use to help lift
the curtain and see what is happening
behind the scenes during gameplay
especially if you want to watch it in
real time like we are right now
since your time is limited while in
subspace it makes sense that there would
be a timer kept somewhere in ram that
keeps
track of how much time is remaining
until it forces you to exit
we can find it by simply watching the
ram and looking for changes
this ram viewer has a feature that
highlights activity in red to make it
easier to see where changes are
occurring
after a bit of observation it looks like
the countdown is happening here
at address 4b7 once it reaches 0
we are booted out of subspace i didn't
do anything technical here besides watch
the ram while i was in
subspace to see if i could find a
counter i have a save state just before
mario entered subspace so
let's reload it enter the door and pause
the emulator
okay the timer has been set to start at
60 hex
let's manually edit the ram to increase
the timer from that starting point of 60
to a much larger value of ff the maximum
8-bit number
to increase the time we are in subspace
and
hey there is a lot more of the theme
isn't there i've always enjoyed this
rendition of the mario one theme and it
is nice to hear more of it
in the case of modifying ram in order to
listen to the rest of the music we just
waited until the program
set the value of the timer as we entered
subspace
and changed it to a higher value while
this was an easy way to get it to do
what we wanted
it would be nice to not have to
interrupt the timer and edit ram
manually
perhaps it would be best to modify the
code so it sets the timer to a higher
value
for us so we're going to move the
location of our change from ram
to rom to the area where the game's code
resides
and i'll walk you through this part
since we know the location in ram for
the timer we can set a break point in
the code for any time the value at this
location
is updated we also know that the moment
it is set to our starting value happens
right after we enter the door to
subspace
if you look inside the 6502 debugger
window to the left of the game the code
is in the long
box on the left to the right of the code
are various numbers we can monitor as
well as numerous features we can use
breakpoints allow us to specify
conditions that will halt execution of
the game the moment those conditions are
met
this will give us an opportunity to make
observations or even make changes on the
fly
so let's click the add button here and
add a break point for our timer location
in ram
address 4 b7 we are looking for a
right to that location the moment when
the game sets the timer to 60
so we will check the right box let's
leave conditions blank for simplicity
now back to the game window let's walk
through that red door
okay we hit a break point and execution
halted
let's look at the code window on the
left the instruction sta
stores the value from a which you can
see in this box over here
to the specified address location since
the value of a
is currently zero this statement appears
to serve as an initialization
you can see we are storing the value in
a to several other locations at this
point in code as well
initializing them all to zero so this is
not quite where we set our timer start
value
we'll click run and continue execution
ah
we've reached the next break point and
this one looks promising
we are once again storing the value in a
to our timer location but
this time we loaded a hex value of 60
into a
in the previous instruction this is the
starting value for the timer that we
observed in ram
earlier this lda statement at address
95a1
is what sets our timer's start value to
60x
since we just passed over that lda
command that loads 60x into
a let's change the value over here in
the a box
to f f the same long timer value i
jammed into ram earlier
keep your eye on 4b7 in ram and i will
click
step over to execute just the next
instruction
our sta instruction here aha
we have loaded ff into ram just like
earlier
but we did it by hijacking the code with
our debugger
instead of directly editing the ram if i
disable the breakpoint and continue
execution you can see the longer timer
counting down as expected
we found it so the code we are
interested in is the instruction
lda at address 95a1
and the hex value of 60 right next to it
at address 95a2
while the debugger lets me edit code and
change the value the lda instruction
uses
let's try a different approach one that
doesn't require our direct intervention
at all
i no longer need the debugger or the ram
viewer because i have the address with
the value i want to change
the unmodified original value and the
desired value i would like it to be
i don't want the music and subspace to
repeat so i'm going to shorten the
desired start value to d2
that's about enough time to hear the
last little note of the mario 1 melody
and then transition back
into the regular music from this point
there are several options to push this
new timer start value
one option might be to modify the mario
2 rom file itself with our change
a second option would be to create a
cheat code to patch the rom
on the fly several emulators have a way
to generate these codes given the
necessary criteria
we know the criteria so let's use the
cheat search tool to plug in our numbers
address is 95a2 the value we want to set
it to be
is d2 the compare field is where we put
our original value
of 60x now we'll click add this cheat is
now set to automatically activate when i
load up mario 2 in the emulator
i can use this checkbox to turn it on
and off
but perhaps what is more interesting
here is that the software
generated the appropriate game genie
code to do the same thing
so if you have a game genie and desire
enough time to hear the full mario 2
arrangement of the mario 1 theme while
you are inside
subspace just use this code it isn't too
difficult to create a game genie code
manually by translating our address and
values into the appropriate letter
sequence
but i thought we would let the emulator
do it for us since the feature is built
into the software
as for mario 2 itself i should point out
that picking up a mushroom in subspace
interrupts the music in order to play a
short tune
and of course increasing the time and
subspace takes away from the challenge
of pulling as many coins as you can
before the timer expires
that said i hope hearing the full theme
and subspace will put a smile
on your face
in the prototype version of super mario
bros 2 each playable character was made
up of four
tiles just like doki doki panic two
tiles are used for the head
and two tiles are used for the body
three solid colors plus one for
transparency are used for each tile
nintendo elected to enhance the
graphical appearance of the characters
and add whites to the eyes of each of
them via a
fifth sprite consisting of a white block
and placing that block behind the head
tiles
here we are again at our spot next to
the vine stepping in front of the door
demonstrates what i assume to be a
sprite priority issue between the door
and the white block for the eyes
while this demonstrates that the fifth
white block sprite does
exist let's make it more obvious if you
look at line 220 here in our ram window
locations 220 224 228 and 22c
represent the vertical location for
mario's left head tile right head tile
left body tile and right body tile if
you watch them when mario jumps they
decrease as he goes up
we're going to lock them in place this
ram window lets me freeze values
so let's change the vertical values of
the head tiles to each b1f
change the vertical values of the body
tiles to each b2f
and freeze all four values now
all that is left is the white block that
goes behind the eyes
since the game will still function
normally we can now play
as a floating white block this
is rather challenging but it is doable
it reminds me of adventure for the atari
2600
since mario's head normally bobs as he
walks so does the little white block
any item mario carries will still appear
above where his head normally would be
since we didn't freeze the graphics for
the tiles mario's body continues to
animate the way it should
it just does so locked at the same
vertical position at the top of the
screen
this also lets us observe another bit of
trivia if you watch the mario sprite at
the top when i jump
off this cliff to trigger a death you'll
notice that it still updates to the oh
no
small dying mario like you see when you
run out of health
we never see this under normal
circumstances but
the sprite change is most likely part of
any death sequence
okay we'll unfreeze these values and get
mario back to normal
at least for the moment we're going to
mess with the graphical references a bit
let's return to our 220 line in ram the
value immediately to the right of each
of the vertical positions is an address
in our pattern table
these values indicate which graphical
tiles we are using to create mario
if i jump you see each of the four tiles
change to the tiles for the hands and
the air
and the feet apart mario lands and they
return to their original values
when mario turns around the head
graphics trade places and the body
graphics trade places
you'll also notice that there is a value
to the right of each of these addresses
that changes depending on if mario is
facing right
or left it specifies whether the tiles
should be flipped horizontally or not
if i freeze all four of them you can see
that mario's tiles do swap
places but they haven't flipped properly
let's unfreeze them
now what we could do is change the tiles
we are using for mario's head
and freeze them let's use pattern table
values 8a
and 88 will also freeze the horizontal
flip locations
and that's actually a little disturbing
this is a pretty crude graphical cheat
we are just forcing
tile values to stay the same in two
locations in ram
and since i froze the flip values as
well
mario's head always faces to the right
even if his body faces to the left
this makes climbing the vine also rather
creepy
the music changed the vertical position
of the sprites changing mario's head
into birdo's head
all of this started by simply watching
values in ram as i moved mario about the
screen and performed various actions
it is a good starting point for
experimentation give it a try and see
what you can find
don't be surprised if you get a bit
carried away which is exactly what
happened to me
instead of freezing ram i messed around
with the lookup table containing which
graphics to use for various actions
and replace them with what i thought was
the appropriate birdo head
i used birdo getting hit by the player
for pulling vegetables from the ground
and also thought it would be funny if
the mouth opened when you jump
doing something like this makes a lot
more sense as a patched rom you could
just replace the playable character
graphics with birdo graphics
and leave the lookup table alone it
would likely make palette changes a bit
easier
as well nevertheless here are all of the
currently active codes you
see on the screen right now in case you
want a starting point for messing around
let's talk about animation if we examine
the ppu pattern tables for doki doki
panic and the mario 2 prototype you can
see the water animation
cycling on the far right side of the
window toward the bottom of the table
for the retail release of mario 2
nintendo elected to add more animation
to liven things up
the right pattern table in this example
shows animation for
cherries tufts of grass leaves on a vine
the pow
block the potion and more each of these
continues to cycle through their frames
of animation
but there is a bug not all of the
intended frames are part of the cycle
this is most easily observed in my
opinion with the animation
of the albitos the wings animate
downward in a very smooth motion and
then snap
back to the top the reason this happens
is because the code that is supposed to
start the cycle over
does so one count earlier than it should
the
order a value cycle during the animation
code looks like this
let's skip explaining how the animation
loop works and go straight to the
problem code it is just
a single line the code responsible for
starting the sequence
over loops after we've reached value 26
oops 28 is the last number
the good news is that a single statement
can be changed so that 26 is instead
28 and that is all it takes to get all 8
frames of animation
for each of the animated tiles to work
properly
a fix has been around for a while and is
easily implemented either via a rom
patch or a single game genie code
let's check out all of the animations
the original seven frame sequences are
on the left
and the new eight frame sequences are on
the right the albitos has
one extra frame drawn for when the wings
move upward
and the animation appears to be
noticeably smoother others are a bit
more subtle the cherries
used to move faster to the right than
they did to the left
now the movement is much more even it
doesn't really affect gameplay but it is
a nice fix to have
a couple of more notes on animation here
the speed
of the waterfall and the retail release
was slowed down to be a bit
easier on the eyes you can see how much
faster it is in doki doki panic as well
as the prototype
also i'm not sure if you've noticed this
before but the
o in the pow block actually moves a
little to the left when it gets to the
top of the block
if you would like to move the o of pow
back to where it should be
you can manually edit the mario 2 rom
file and change these values
you can also search for a patch file
from the community
if you do not wish to edit the rom
yourself one final bit of trivia for the
conversion to mario 2.
in the original doki doki panic dying
would play a short sound effect
mario 2 it would only play the short
death tune
the sound effect arrives via dpcm but
the sound for mario 2 mutes dpcm
when changing music tracks this can be
restored thanks to a patch
finally i think it is worth mentioning
that there is at least one revision of
the american release of super mario bros
2.
i haven't done a full study of it myself
but it has been documented that at least
one of the changes
present in the rom is a bug fix for a
problem that can occur while fighting
fry guy
fry guy splits into smaller parts after
you have hit him three times
when the player throws a block at one of
the mini fry guys he disappears in a
puff of smoke
after defeating all of them a door
appears because the boss has been
defeated
in the first version of mario 2 revision
0 if you will
tossing a mushroom block and defeating a
mini fry guy while shrinking at the same
time
due to taking damage will cause any many
fry guys hit by the mushroom block
to fall off the screen instead of
disappear
after defeating the remaining mini fry
guys the game will behave as if there
are still many fry guys to defeat
and the exit will not appear with
nothing left to do
the player has no choice but to reset
the game in revision 1 of mario 2
hitting a mini fry guy while shrinking
will no longer result in the fall off
the screen problem
well that was a lot of mario 2 trivia
and code walking
i hope you enjoyed this peek behind the
scenes of the international release
of super mario bros 2. until next time
thanks for watching