Colonies: population, farms, factories

Colonies : population, farms, factories; support/discussion/questions

Moderator: thunderchero

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7929
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Colonies: population, farms, factories

Post by thunderchero »

Spocks-cuddly-tribble wrote: Mon Apr 20, 2020 8:32 am
thunderchero wrote: Sun Apr 19, 2020 10:23 pmI even had 8 bytes open lol
This doesn't sound right, shouldn't be more than 1-2 bytes (nops) left.
I had 8 bytes after moving code around before adding this.

xor ecx, ecx (looks like an unused register)
mov cl, 5
xor edx, edx
idiv ecx

after adding that I had 1 byte left. :wink:
But as I said that caused CTD on turn processing
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1925
Joined: Sun Apr 27, 2008 2:00 am

Re: Colonies: population, farms, factories

Post by Spocks-cuddly-tribble »

Then, as told, you missed recalculating xrefs from or into moved code. My second workaround (*13/64 rounded down, instead of div 5) shouldn't require messing with this.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 7929
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.

Re: Colonies: population, farms, factories

Post by thunderchero »

I checked xrefs from or into moved code with ida after I moved code and they were going to and from same locations as before. I compared original and edited side by side. If any xrefs are wrong it will not display as blocks in ida.

any way this works so it does not matter. :grin:
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1925
Joined: Sun Apr 27, 2008 2:00 am

Re: Colonies: population, farms, factories

Post by Spocks-cuddly-tribble »

I think I see the problem. Asm integer divisions are even more intricate than my suggested code.

Instead of: xor edx, edx
we'd need:
mov edx, eax
sar edx, 1F
i.e. 3 more bytes (and even then there could occur further issues)

That's why most patches stick with workarounds and floating point calculations instead of using div (and most guys try to avoid asm coding whenever possible). Sorry for wasting your time with this.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
Post Reply

Return to “Colonies : population, farms, factories”