[Source code on Github](https://github.com/donno2048/zip-quine)
In a former post, I explained the tricks I discovered that allowed me to create a snake game whose every frame is code for a snake game.
A big problem I faced was cross-compiling as that would mean the output would have to support both operating systems, so it would be very large and would be hard to fit in the terminal.
The trick I found was treating the original program as a generator that way the generated programs can be not self-similar to the generator but only to themselves.
Then I realised I could use the same tactic and abuse it much further to produce the program in the video.
The generator is not very complex because of this method but almost all of the code is macros which makes the payload (pre-preprocessing) very small which I quite like, but as a side effect now the ratio between the quines payload size and the pre-preprocessed payload is absurd.
Another small gain was achieved by making macros for constant string both in string and in char array versions, that way we can easily both add them directly to the payload and use them in the code without needing to do complex formatting later to make the code appear in the preprocessed playload which I'm very happy about because it seems like (together with the S(x) X(x) method I described in the former post) as the biggest breakthrough that could lead to a general purpose quine.
I couldn't force gcc to let me create n copies of char formatting string so I used very ugly trickery with `#define f4 "%c%c%c%c" #define f3 "%c%c%c" #define f10 f3 f3 f4` and used those three macros... Maybe there's a way to tell sprintf to put the next n arguments as chars that I don't know about...
Another trick I thought of is tricking the fmt to format without null chars so that I could do pointer searching and arithmetic without saving the size of the buffer, then fmt-ing again correctly.
The last trick was a very clibrated use of a `run` macro used to initiate the payload and to run the program to generate the quine and to format the payload, it's hard to explain the details without showing the code, so if it sounds interesting I suggest you read the `run` macro and the two uses (there's one that's easy to miss in the S() or the payload).
The rest was basically reading about the ZIP file format to be able to even do this.