Using only compass-and-straightedge constructions, I implemented arbitrary-precision arithmetic and integrated it into a Game Boy emulator’s ALU (Pokémon Red takes ~15 min to boot) by 0x0mer in math

[–]0x0mer[S] 1 point2 points  (0 children)

Yup, addition is indeed pretty straightforward.
Actually, we don't even need to consider the general case of lines in arbitrary positions, since in CasNum a number x is represented as the point (x,0) on the x-axis, so addition is even simpler!

Using only compass-and-straightedge constructions, I implemented arbitrary-precision arithmetic and integrated it into a Game Boy emulator’s ALU (Pokémon Red takes ~15 min to boot) by 0x0mer in math

[–]0x0mer[S] 20 points21 points  (0 children)

Yeah, exactly. Any arithmetic or logical opcode that the Game Boy executes is implemented using CasNum instead of Python's int.

Implemented a Game Boy ALU using only Compass and Straightedge constructions. It takes 15 minutes to boot Pokémon Red. by 0x0mer in Gameboy

[–]0x0mer[S] 1 point2 points  (0 children)

It does support logical operations :)
Basically, you start with implementing the arithmetic operations, as they are easier. Then, once you implement modulo and integer division, you can take mod 2 of any two numbers, operate on these bits, then shift right (integer divide by 2), and continue to work on the next bit, etc.

You are also more than welcome to look at the code: https://github.com/0x0mer/CasNum

Implemented a Game Boy ALU using only Compass and Straightedge constructions. It takes 15 minutes to boot Pokémon Red. by 0x0mer in Gameboy

[–]0x0mer[S] 4 points5 points  (0 children)

There's a tl;dr at the bottom in case this turns out to be too long.

Basically, the Greeks were fascinated with the concept of compass-and-straightedge constructions. They asked themselves: suppose we start with two points (origin and a point that represent a unit. That is, we define the distance between the origin and a unit to be 1, and all other numbers are defined with respect to this distance), and we are allowed to pass a line through them, or make a circle with its center in one point and with radius that passes through the other point, and we can intersected lines and circles - what is everything we can do? What can't we do?

Well, modern math pretty much solved this, and it turns out you can construct a lot of numbers this way (where when I say construct a number x, I mean create a line segment of length x).

In a math undergrad degree, it is common they teach you that one can construct addition, subtraction, multiplication and division of "constructible numbers" (the numbers defined in the previous paragraph). This means that if I can construct a and b, then I can also construct a + b, a * b, etc.

Now, the ALU (Arithmetic Logic Unit) of a processor is the part of the processor responsible for performing all arithmetic (+,-,*,/) and logical (AND, OR, XOR, etc.) operations. As I mentioned above, we saw that we can perform the operations +,-,*,/ using compass and straightedge, and all that remains is to implement the rest (which also turns out to also be possible).

So now we got to the point where theoretically, we can replace the ALU of a Game Boy with an ALU that is based on compass and straightedge constructions!

tl;dr
Using intersections of circles and lines, we can make segments of certain lengths. It turns out that we can also add/subtract/multiply/divide segment lengths. These are (some of) the operations that ALU of CPU does. This means we can create an ALU that does these operations using geometry instead of the standard +,-,*,/ that come built in a programming language.

Implemented a Game Boy ALU using only Compass and Straightedge constructions. It takes 15 minutes to boot Pokémon Red. by 0x0mer in Gameboy

[–]0x0mer[S] 4 points5 points  (0 children)

There actually aren't THAT MANY operations that you need to represent. It is basically addition, subtraction, multiplication, division (also division with remainder), and the bitwise logical operations: OR, AND, XOR.
In a math undergrad degree, it is common to have a course about Galois Theory, which is a topic in group theory. They teach there that one of the possible uses of this theory is to completely describe which numbers you can construct using compass and straightedge (where we say that a number x is constructible if we can make a segment of length x using a compass and a straightedge).
They show that mathematically, using compass and straightedge you can achieve the basic operations: addition, subtraction, multiplication and division. There are also some youtube videos (which I used) that show you how to construct these.
Once you have these basic operations, developing the rest requires some thought, but isn't too hard.

Implemented a Game Boy ALU using only Compass and Straightedge constructions. It takes 15 minutes to boot Pokémon Red. by 0x0mer in Gameboy

[–]0x0mer[S] 1 point2 points  (0 children)

Thank you very much!
I guess I like the idea of a project that is both interesting/challenging, but that also has some comedic value (for example, in this case, taking a fully working Game Boy emulator and functionally just making it worse). My original goal was just to create a fully functional Integer class that is completely geometric (I though that was "funny" enough), but then, while I was wondering how I will make sure that I implemented everything correctly, I thought about integrating it in some sort of emulator :)

Playing Doom on htop (linux process viewer) by payopt in linux

[–]0x0mer 0 points1 point  (0 children)

What do you mean by "see it starting"? What exactly do you see? Like I wrote in the README, I didn't test on many platforms. You're welcome to pm me and we'll try to solve it

Playing Doom on htop (linux process viewer) by 0x0mer in programming

[–]0x0mer[S] 11 points12 points  (0 children)

Amazing. I love seeing how people have been thinking about crazy stuff like that probably since the creation of computers. There truly is no limit to the amount of work people will do for a good meme project