Just some statistics

152 views
Skip to first unread message

Miguel Ángel LS

unread,
Mar 24, 2012, 9:02:22 AM3/24/12
to syndicate...@googlegroups.com
I've made a listing of all the functions in swars.S to know which function is most used. It's func_45b40: 649 times.

I don't know assembler, so I can't help with this but I think it would be a nice step forward if the names of the functions had a meaning (I know they're automatically written by the decomp).

One final thing: if I'm not wrong, most of the bulk it's data (strings) and blank space, so the code is not that big (I mean, it's not near the 7.7MB/382719 lines of text).
listado.txt

dizz...@gmail.com

unread,
May 17, 2013, 10:46:10 PM5/17/13
to syndicate...@googlegroups.com
its probably something like a random number generator

lis...@gmail.com

unread,
Oct 13, 2014, 5:36:28 PM10/13/14
to syndicate...@googlegroups.com
The function func_45b40 (at offset 45b40 in original EXE) is an implementation of random generator. The function next to it is the same. They only differ on where they store prevoius result  - most likely one is used for random numbers which require to be identical for all players (in network game), and 2nd generates random numbers specific to a player (ie. for effects randomization which is not synchronized between player). In KeeperFX (which is remake of Dungeon Keeper, which is based on the same engine) these are named UNSYNC_RANDOM() and ACTION_RANDOM().

Anyway, KeeperFX could help in giving names to many functions. Same goes with INSTALL.EXE from SW, which has debug symbols (function names and variable names) left inside.

For example, at 13C220 we have _Unsmack() function from RAD Smacker library; then goes _SmackDoPCM at 13C5F0, and _SmackGetSizeDeltas, _SmackGetRect, finally _SmackRemapTables at 13CF60.
And not only Smacker is easy to find - at 41950 we have W?setup_language$n()v, which is called from W?game_setup$n()l at 41668. At 8C510 is LbIKeyboardOpen_, and below at 8C554 - LbIKeyboardClose_.
At DC6A0 there's memory allocation - LbMemoryAlloc_, then LbMemoryAllocLow_, LbMemoryCheck_, LbMemoryFree_, LbMemoryGrow_ at DC920 and other memory related routines.
E0C90 is LbScreenSetup_, E0CC0 - LbScreenIsModeAvailable_, then sprites loading routines, and at E0FFB we have standard C library sprintf_.

I found a lot more, but to really see it you need to use IDA Pro.

I think about 1/3 of all the functions in SW can be named by comparing them to debug binaries of Magic Carpet, SW Install and Dungeon Keeper.
It just requires a lot of time to do so.

Reply all
Reply to author
Forward
0 new messages