All right, hello, welcome to air correction for Dragon Quest past races.
I almost canceled this talk because I'm recovering from the flu.
So my voice is, I'm not sure if everyone can hear me from the back.
I'm going to do my best to try and speak up.
Yeah, we'll see.
So first of all, let me just start and set up the stage because I'm not sure if everyone here is aware of what a Dragon Quest past races.
Dragon Quest is a game that was released in 1986 in Japan for the family computer.
This is a console that does not have a save function built in.
In this game, you walk around the world, fighting monsters to level up your character until you become strong
enough to save the world.
And you save you have to go back to the initial area in the game, speak to the king who will give you a
spell of resurrection or cutscene or doom on, which is a bunch of gibberish, basically.
Random Japanese, here I got our characters, 20 of them in the first game.
Of course, you'll write to those characters in your trusty notebook.
And when you come back to the game at the later time, you come into the save,
ask the load screen and you will enter your pass race back into the game to restore your save.
Of course, if everything goes well, but sometimes things go wrong and you may encounter
this screen, which is where the password is wrong, either you wrote it wrong or you just
entered it wrong on the load screen and it won't let you save or load your game again.
So in this case, this happened to me, this happened to millions of Japanese children back in the
day, unfortunately. So it happened to me a couple of times and I thought, well, surely there
has to be a way that we can analyze this wrong pass race and be able to restore it to substitute
the characters and find out where it was transcribed wrong. And thankfully, yes, it is possible
and I managed to do it and I'll show you. So first of all, we have to see what makes up this
pass race, how is it constructed and how do we decode it? So this is, these pass races are composed
like I said, of 20, here I got a carcass, there are 120 bits of data here, they are encoded into
six-bit characters, it's a subset of the alphabet in Japanese, it contains information like the
player's name, stats, the inventory, some event flags, there's a three-bit encryption key that's
just a randomizer and there's an eight-bit check-up which is helpful for restoring the correct
values. I'm not going to go too deep into the actual technical details of decoding since it's a
little bit convoluted and we don't have a lot of time but we would first convert those characters
into their indices as seen in this table, then taking those bytes, those encrypted bytes,
this have to be decrypted in this algorithm that you see here. So you can see that I'm doing
some very serious work because there's a lot of complicated rascode on this page. And once those
byte values are decrypted, they can be repacked into bytes and yield the decrypted and decoded
spell and this is how, so there's also, this is where the check-up can be checked to compare it to
the remainder of the byte sequence that you get in the output. And once everything is decrypted and
decoded, this is how basically the values that are saved in the game are laid out and as you can
see, it's not like you have sequentially printed player name and then the player inventory,
et cetera, et cetera. All those values are kind of broken up into individual bytes or even
if you bits at a time and then they are kind of spread out all over the sequence which is also
helpful because it means that if there's an error in a character in the middle of the sequence,
it's going to affect many different pieces of data. So it makes it easier to tell what the correct
sequence is. So now to correct an error in the passphrase, the way that we operate is that
we take the error passphrase that the one that doesn't go through, substitute every single
character with every other possible character that could go in its place and then we try to decrypt
and decode it and if there checks some matches, then it is valid passphrase and it will become
a candidate that we can list out to the user and this is what it looks like without any restrictions.
I just took like a random passphrase that I found online, substituted one character and I passed
it through to my program and here you can see there are two possible substitutions of
characters that yield valid passphrases and there's a few different so obviously this is all
on Japanese so I'm sure it's going to be hard to understand but here's a few differences here
in the equipment and also in the player name that can be used to identify which one is the correct
one and it's in fact the top one not that this matters here but yeah so it could be the number
of valid substitutions is not typically high but it can range from one to six or something and
then unfortunately it didn't stop here in 1987 Dragon Quest 2 came out it also did not come with a
save function and unfortunately it's not just a little bit larger than Dragon Quest 1 it's about
three times larger it has three player characters it has more variable game state it has a larger
alphabet and some more characters that you can use for encoding and that means the passwords are
52 characters long which is very annoying to type in and also much more annoying to transcribe
in your little notebook and it makes you much more likely to make mistakes so it's also a little bit
more convoluted the way that it's the data is encoded you can have bits that are or aren't added
like in the middle of the stream depending on whether or not your inventories full very very strange
stuff thankfully it was documented in this the basic the issue of June 1987
I don't have this issue but I found I managed to find some information based on that magazine
online so this is how I was able to do the the coding and the encryption portion of my program
for Dragon Quest 2 now and because there's so many more characters there's also more possible
substitutions and that means the number of valid passbraces that can be corrected from the
error to one is also larger so we have to find a way to restrict the results that we have one
easy way to do this is we know what the player's name is gonna be so you can just pass it into the
program and whenever the player name is decoded if it's not the right one then we can just
eliminate that result from the pool there's also some other kind of easy to remember
properties like some event flags that can be set just to make sure that you know so obvious
obviously wrong passbraces are not included and then we can also filter some substitutions
that you'll invalid value so for example you have some 16 bit values like your gold or experience
that in fact in game the you know logical maximum is below the limit of 16 bit value so
we can easily tell that if we are between like 10,000 and 16,000 then it's not going to be
an actual valid passbrace on this the player cheated so those are some ways that we can
limit the number of results that we have and this is one example this is another passbrace
which looks like it might you know be bullshit but it's a real one it works and so I took that
and I did a replace a random character and I fixed the name in the input arguments and there's
only one valid substitution which is a correct one of course so that's an example of how to use
this program which is called rejuven and if you want to take a look at the source code if you want to
play dragon quest one or two in Japanese for the family computer it's something you're worried
you don't have to be worried about you know mistranscriptions anymore you can be protected by
rejuven here so thank you very much