[90] There and Back Again
- Conlan Walker

- Aug 4, 2023
- 2 min read
I am fed up with this, so I'm going back to SDL2. This realization only happened on Wednesday, so I made 2 things in between then and Monday.
One is some sort of primitive assembly preprocessor thing that hijacks the C preprocessor, and the other one is my own partially-broken Conway's Game of Life,
written in 6502 assembly.
I wrote the Game of Life clone to be used in skilldrick's easy6502 emulator thing:

I say the program's partially-broken, as it's only the edges that aren't being updated properly.

I spent a good 40 minutes rendering about 102 frames of this, but I only bothered to include 51 for this GIF (each frame takes about 17.5 seconds).
The reason it takes so long is because of a combination of slightly unoptimized code, and the fact that this emulator written in javascript is horrendously slow.
(I think at some point I measured the instructions per second to be no more than 8kHz or something.)
This is the actual 6502 source code:
And this is the preprocessor thing:
Now, for SDL2, I wanted to build it from source, so I could customize what subsystems, routines, et cetera are included. This is mainly to manage binary size.
Because I wanted to statically link it too, I had to go through a few more hoops, as the SDL wiki intentionally does not disclose how to compile the static version.
Here are the batch scripts I made that handle the build steps:
This one handles the CMake stuff:
This one handles the build stuff once the CMake stuff has finished:
I also reworked my copy_dat and countLines scripts:
copy_dat.bat:
countLines.py:
It might've taken 2 days, but I finally got it working exactly the way I wanted it to.

I removed a lot of stuff, so here's a (probably incomplete) list of the stuff I removed:
Haptic subsystem
CPUInfo subsystem
Locale subsystem
Misc subsystem
Sensor subsystem
Filesystem subsystem
File subsystem (not to be confused with Filesystem)
Power subsystem
The HIDAPI subsystem
CD audio driver
Virtual-joystick driver
HIDAPI joystick driver
Raw input joystick driver
OpenGL support for embedded systems
OpenGL support
DirectSound support
DirectX 9 support
DirectInput support
Libudev support
3DNow! assembly routines
AltiVec assembly routines
MMX assembly routines
SSE assembly routines
SSE2 assembly routines
Doing this shaves off about 20% of what SDL2's binary size would be otherwise, and it should do this without really affecting its functionality negatively.
To do a quick test to see if I set up SDL2 properly or not, I just made a small program that opens a window, before closing it after a second has passed:
Which seems to work just fine.

My original goal was to keep the release's binary size under a few megabytes total, whose requirements seem to have been met.

Next week, I'll probably re-implement my audio mixer.

![[158] Most Important Brick in the Least Important Wall](https://static.wixstatic.com/media/df100d_f70be6ae4318455fbbc605cd1069c6ee~mv2.jpg/v1/fill/w_980,h_410,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_f70be6ae4318455fbbc605cd1069c6ee~mv2.jpg)
![[157] Mail Order Sacrifice](https://static.wixstatic.com/media/df100d_e284fa6c51b04524bab9d3cf9f1f6441~mv2.png/v1/fill/w_980,h_382,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_e284fa6c51b04524bab9d3cf9f1f6441~mv2.png)
![[156] Moat of Babble](https://static.wixstatic.com/media/df100d_091e451794b14aecb494a16c15c966c3~mv2.png/v1/fill/w_980,h_705,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_091e451794b14aecb494a16c15c966c3~mv2.png)
Comments