Function list

From sc2k-reverse
Revision as of 16:44, 6 March 2025 by Araxestroy (talk | contribs)
Jump to navigationJump to search
1195
1195
SimCopter One reporting heavy traffic!
This page or section is under significant construction. It may be a large repository of data that's constantly being updated, or there may be a large rework in progress. There is a good chance the contents of this page will have dramatically changed next time you look at it.
Please check the history before making any edits to ensure any changes you make won't conflict with anyone else's.


This is a table of functions in SimCity 2000 that have been at least partially reverse engineered and given names. It is probably going to be unpleasant to update, but at least it looks nice and you can sort it.

When adding new functions to the table, please make sure you insert them into the appropriate order by thunk address (the function that just has a jmp ActualFunctionBody instruction in it). If/when it gets too unwieldy we can split it out into multiple tables.

Uncategorized functions
Thunk address Main address Return type Calling convention Function name Arguments Status Related functions Notes
0x40130C 0x45F760 BOOL __stdcall SimulationDoDisasterTick Barely explored Called from SimulationStartDisaster
0x4013ED 0x42BCA0 int __cdecl SimulationCalculateOrdinanceCost DWORD dwOrdinance Returns the effective cost of an ordinance
0x401460 0x44CF60 char __cdecl SimulationProvisionMicrosim __int16 a1, int a2, __int16 iTileID Barely explored iTileID is the only argument used; needs some RE work for sure
0x4015E6 0x4731E0 int __cdecl SimulationPrepareBudgetDialog int a1 Mostly understood arg a1 only referenced on line, seems to be more like "BOOL bUseParentWindow"
0x401672 0x441E50 int __cdecl SimulationGrantReward __int16 iRewardID, BOOL bAddReward Mostly understood Adds a city progression reward if (bAddReward), removes it if (!bAddReward).
0x40174E 0x42B4D0 int __cdecl SimulationPrepareDisaster DWORD *a1, __int16 a2, __int16 a3 Somewhat understood Seems to prepare the starting location for disasters.
0x401820 0x413520 void __stdcall SimulationProcessTick Mostly understood Called from GameDoIdleUpkeep based on game speed Advances the calendar date and performs all appropriate daily/monthly/etc. tasks. May need better name?
0x401CA8 0x464550 int __stdcall SimulationUpdateWaterConsumption Barely explored Called whenever tiles are placed and on SimulationProcessTick day 2 Vanilla SC2K doesn't call this when tiles are placed on cities over 50,000 pop.
0x401E65 0x471BC0 char __stdcall SimulationDetermineCityCrisis Somewhat understood Called on the last day of the month and from sub_406A50 Changes the city status line if there's a new demand, and also starts disasters.
0x4022FC 0x4358B0 int __cdecl SimulationGrowthTick __int16 a1, __int16 a2 Barely explored Called from SimulationProcessTick on days 4-17 The arguments and algorithms are not yet understood.
0x402527 0x45CF10 int __stdcall SimulationStartDisaster Somewhat understood Called from GameDoIdleUpkeep Calls the appropriate disaster creation function and then runs disaster ticks
0x4026B2 0x4734A0 int __usercall SimulationGrowSpecificZone int a1@<ebp>, __int16 iX, __int16 iY, __int16 iTileID, __int16 iZoneType Barely explored Called from SimulationGrowthTick Might be an omit-frame-pointer function?
0x4026F8 0x467860 int __stdcall SimulationUpdatePowerConsumption Barely explored Called whenever tiles are placed and on SimulationProcessTick day 21 Vanilla SC2K doesn't call this when tiles are placed on cities over 50,000 pop.
0x402A3B 0x405AB0 DWORD __thiscall GameDoIdleUpkeep CWinApp* this Somewhat understood Called from CWinApp::OnIdle via the class CWinApp vtable Could stand to have a better name.
0x402D2E 0x4734A0 __int16 __stdcall SimulationCalculateBudgetUpdates Barely explored
0x403017 0x4142C0 int __stdcall SimulationProposeMilitaryBase Somewhat understood Called from SimulationProcessTick day 23 and from "gilmartin" cheat
Thing functions
Thunk address Main address Return type Calling convention Function name Arguments Status Related functions Notes
0x402464 0x450890 int __stdcall SimulationDoThingTick Barely explored Called from GameDoIdleUpkeep via sub_401DBB Does the individual simulation ticks for Things every 30-45 ms.
0x401992 0x4548C0 char __usercall SimulationThingTickMonster int a1@<ebx>, __int16 iXTHGIndex Barely explored Called from SimulationDoThingTick The function signature of this one is odd and needs investigation.
0x401EBA 0x452FA0 int __cdecl SimulationSpawnMaxisMan __int16 iDisasterID Barely explored Creates the Thing for Maxis Man and determines based on iDisasterID what his behavior should be
0x4024AA 0x455020 char __cdecl SimulationThingTickMaxisMan __int16 iXTHGIndex Barely explored Called from SimulationDoThingTick If you shoot down a helicopter and it lights something on fire, it's your own dang fault
0x402ED2 0x4540C0 __int16 __cdecl SimulationThingTickHelicopter __int16 iXTHGIndex Barely explored Called from SimulationDoThingTick
Sound and music functions
Thunk address Main address Return type Calling convention Function name Arguments Status Related functions Notes
0x401096 0x4251D0 int __thiscall SoundPlaySound int* this, int iSoundID Mostly understood Called in so many places Calls through to sub_4802B0, which does the buffer loads and calls to sndPlaySoundA
0x401389 0x480890 MCIERROR __thiscall MusicSendMCICommands unsigned __int16* this, char* szMidiPath Understood Called by MusicPlayMidi Sends the actual MCI commands to play/stop a MIDI file
0x401479 0x480770 MCIERROR __thiscall MusicPlayMidi unsigned __int16* this, int iSongID Understood Called by MusicPlay Turns iSongID into szMidiPath
0x4015FF 0x480B20 void __thiscall AllocateSoundBuffers DWORD *this, int a2 Barely explored Called by CMainFrame:OnCreate Allocates sound buffers; replaced by sc2kfix
0x401A9B 0x425290 int __thiscall MusicPlayNextRefocusSong unsigned __int16** this Understood Called in a few places Loops through the non-event music; replaced by sc2kfix
0x401CE9 0x425220 int __thiscall SoundStopSound int* this, int iSoundID Understood Called in so many places Does a few checks then blasts out sndPlaySoundA(0, 0)
0x401F9B 0x480140 void __stdcall LoadSoundBuffer int iSoundID, void* lpBuffer Understood Called before a few sound calls This and many other sound functions are replaced by sc2kfix
0x402414 0x425260 int __thiscall MusicPlay unsigned __int16** this, iSongID Understood Called by anything that changes the music Basically just a trampoline to MusicPlayMidi
0x402BE4 0x480AE0 MCIERROR __thiscall MusicStop int this Understood Called by anything that stops the music Sends an MCI_CLOSE command to the sequencer device
Frequently-reused MFC class functions
Thunk address Main address Return type Calling convention Function name Arguments Status Related functions Notes
0x40219E 0x4815E0 INT_PTR __thiscall CGameDialog::DoModal LPCDLGTEMPLATEA* this Understood Called in so many places Seems to pause the simulation, call CDialog::DoModal(this), then restore the simulation.
0x40281A 0x481300 struct CRuntimeClass* __stdcall CGameDialog::GetRuntimeClass Understood