How to run a city builder on 16 MHz
In the early days of computing, city building games like SimCity ran perfectly on CPUs with a meager 16 MHz clock speed. This may seem impossible to modern gamers who expect high performance from their hardware, but the secret lies in clever optimizations. The core of SimCity's simulation is the Simulate() function found in the s_sim.c source file.
This function handles all the simulation tasks like traffic, fire, power, and crime. Rather than running every update every frame, the game intelligently skips most of the simulation, calling certain update functions only at specific intervals. This is achieved by using a mod16 parameter that loops through values 0 to 15, determining which parts of the simulation run in each frame.
This optimization drastically increases the speed of the simulation without sacrificing much in terms of gameplay. The same principle of distributing work across multiple frames extends to other areas of game development, such as rendering. Assetto Corsa, for example, updates only a few cubemap faces per frame depending on the reflection quality setting.
By recognizing which parts of a program's work can be spread out over time, developers can achieve impressive performance on even the most limited hardware.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.