Johnny Cai

Electrical Engineering Student, McMaster University


Screenshot

Recreation of the game Factorio.

It uses OpenGL for rendering and loads runtime data using Python. It is written in C++17, built via CMake, with automated builds running on Microsoft Azure.

I spent a significant amount of time optimizing the renderer, making use of threading to reduce frame times. When that was insufficient, I tuned the assembly in hot paths by assessing the compiler generated assembly and restructured code to convince the compiler to emit better assembly and redesigned data structures to take advantage of cache locality.


C Compiler

A C99 compiler I wrote, in C.

It currently supports all the basic language constructs: conditionals, loops, expressions, arrays, pointers, function calls, and so on.

It uses top-down recursive descent with backtracking to build nodes of language productions. The nodes are translated to a custom intermediate language, which are then converted into assembly via macro expansion and register allocation with graph coloring.


Framework to add aircraft to the game Factorio, the API is documented here.

The result is a product of the collaborative contributions from various individuals on GitHub and Factorio Forums - making suggestions, bug reports, and contributing code.

It exploits existing features of the game to give the illusion of taking off and landing. Imitating takeoff using two cars with different collisions, one for the grounded plane, another for the airborne plane. Information about planes is serialized in Lua and stored across dummy entities which are created only for holding the serialized data


Vim LaTeX Equation Editor

Edit LaTeX equations in a vim style editor.

I find a vim style editor much faster to use for writing equations. As none of the existing websites supported a vim style editor, I made my own.