Skip to content

Commit a8f15c8

Browse files
committed
write about prerequisite knowledge
1 parent 092e8cc commit a8f15c8

File tree

3 files changed

+81
-10
lines changed

3 files changed

+81
-10
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"cSpell.words": ["decomp", "decompiled", "Typst"]
2+
"cSpell.words": ["decomp", "decompiled", "Ghidra", "Typst"]
33
}

src/introduction/about.typ

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ which is an organized community effort to reverse engineer the source code of
88
the 2003 platform game "SpongeBob SquarePants: Battle for Bikini Bottom" (BFBB) for Nintendo GameCube.
99

1010

11-
=== What You Will Learn
11+
=== What you will learn
1212

1313
The main goal of this book is to act as a complete guide that can take someone
14-
with the #link(<knowledge>, [required prerequisite knowledge])
14+
(with the #link(<knowledge>, [#underline[required prerequisite knowledge]]))
1515
from zero understanding of decompilation and assembly code to being able to read, understand, and
1616
decompile BFBB's C++ source code and corresponding assembly code.
1717

@@ -34,14 +34,78 @@ unearth and give new life to long lost-and-forgotten source code
3434
as if you were a digital archeologist.
3535
It is also likely that your newly decompiled code will run on hundreds of thousands
3636
if not millions of PCs
37-
as the source code will serve as the base for a BFBB PC port.
37+
as the source code will serve as the base for a highly desired native BFBB PC port
38+
(and to perhaps other platforms).
3839

3940
You have an opportunity to become a part of gaming history.
4041

4142

42-
=== What You Will Not Learn
43+
== Prerequisite Knowledge <knowledge>
4344

45+
Reverse engineering is an advanced topic.
46+
The goal of this book is to break it down into digestible parts
47+
that make it easy to follow along and learn.
48+
However, the contents of this book are written in a way that assumes that the reader
49+
has a comfortable foundational understanding of programming and computer science.
4450

51+
=== What you need to know
4552

53+
Here are a list of things that you #underline([do]) need to know before reading this book.
4654

47-
== Prerequisite Knowledge Needed <knowledge>
55+
+ A moderate familiarity with C++ and the language features that the BFBB codebase makes heavy use of:
56+
- Classes, Inheritance, and Object Oriented Programming
57+
- Polymorphism (Virtual Functions)
58+
- Pointers and References
59+
- Callback Functions
60+
- Casting
61+
+ Have an enthusiasm for BFBB and/or reverse engineering
62+
+ How to use Git
63+
64+
Note that a lack of experience with C++ can be made up for with a solid understanding of programming in general.
65+
What ultimately matters is that you have a solid understanding of how to write code.
66+
67+
It is unreasonable to expect to be able to understand or follow along
68+
with this book without having ever written code before.
69+
If you are interested in the topic of this book but have never written code,
70+
it is recommended to learn programming fundamentals,
71+
along with each one of the bullet points above and then come back
72+
with some experience.
73+
74+
=== What you don't need to know
75+
76+
Here are a list of things that you #underline("don't") need to know beforehand.
77+
If you do know them, it's a large plus, but if you don't, don't worry.
78+
You will learn these things while reading this book:
79+
80+
+ How to write or read assembly language, be it PowerPC or any other type of instruction set
81+
+ How to use Ghidra or other binary analysis/reverse engineering tools
82+
+ Math, or anything related to 3D programming
83+
+ Game development or game programming techniques
84+
85+
#quote(attribution: [You, probably right now], block: true)[
86+
But how can we decompile a 3D game without needing to know game programming or 3D math?
87+
]
88+
// TODO: link to the idea later
89+
Great question!
90+
We will explain this idea in more detail later,
91+
but the answer is surprisingly simple:
92+
The compiler will tell you if you're right or wrong.
93+
94+
For now think of it like this:
95+
96+
Imagine you have the formula $x + 1 = 4$.
97+
There are an infinite amount of numbers you can substitute for $x$,
98+
but there is only one correct answer.
99+
You don't have to know anything about the number $4$,
100+
or why the number $4$ is important in this context,
101+
or about $x$,
102+
or why we are adding instead of dividing,
103+
or what the formula means.
104+
You just have to solve for $x$ and that's it.
105+
When you realize that $x = 3$ you're done.
106+
107+
The decompilation process is similar.
108+
Generally speaking there is only one way to write code
109+
that will compile to the same assembly output.
110+
You don't have to even know what the code is trying to do,
111+
you just have to replicate the logic.

src/introduction/what-is-decomp.typ

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ and generally straightforward to program in.
5757
The C++ compilation process involves
5858
a series of steps which translate
5959
the original human written source code
60-
into what ultimately results
61-
in an executable file.
60+
into what ultimately becomes
61+
an executable file.
6262
Refer to @compilation-process for an illustration of this process.
6363

6464
]
@@ -75,10 +75,17 @@ Refer to @compilation-process for an illustration of this process.
7575
If the compilation process is a series of steps
7676
from $A -> B$,
7777
then the decompilation process is simply the same process in reverse
78-
from $B -> A$,
78+
from $B -> A$.
7979
and it looks like this:
8080

8181
#figure(
8282
caption: [The decompilation process],
8383
image("img/decompilation.png", width: 70%)
84-
)
84+
)
85+
86+
It's important to understand that going in reverse is not something that can be done automatically in the same way that source code is compiled to machine code.
87+
Decompilation requires reverse engineering the machine code to understand the intent,
88+
and rewriting code at a high level which matches the same logic.
89+
90+
The process is like trying to deduce the original recipe used to make a cake,
91+
except the only thing you have to work with is the cake which has already been baked.

0 commit comments

Comments
 (0)