ASM-learning group - can't get my code to work right

This forum is for outdated or irrelevant Modding Information that may or may not be 3 months old.

Moderator: thunderchero

Post Reply
User avatar
DOT
Lieutenant-Commander
Lieutenant-Commander
Posts: 100
Joined: Tue Dec 23, 2008 3:00 am
Location: 49°N, 8°E

Post by DOT »

This topic was split from "Crew Experience".

It is extremely unlikely that the modifications from that topic (nor the BotF original code) have something to do with the issues mentioned here.

Since we have 4-5 member who want to learn a bit more about assembler, I suggest you team up and build a learning group.

Please do not spam coding forum with faulty codes or wrong statements. No hard feelings, but this confuses people and modding is hard enough. For the same reason, please stay as short & clear as possible there. For example this could be said in two short sentences (+1 code line asm/hex).

Also note posting of code-rewriting requests on external asm-blocks is not a good idea as well. You will see your topic closed, deleted and/or yourself banned quite soon. Just a prediction.



======================================================




Uh, I didn't check this topic for a while and from my little tests everything had seemed to be okay, but Spocks-cuddly-tribble put rightfully the finger on the error.
So first I have to apologies to all of you for my mistake.

Second, last night I reworked the code (I will post it soon) and while running tests I stumbled over a problem, which is related to the training limit code change:
To quickly simulate high exp crew behaving I gave a training facility a training value of 1000!! (This big value is getting important)
Everything worked fine till the crews reached the limit of 4000 points. (Note: the new treshold values for my reworked code reades 768, 2048, 4608, 8192)
So the ships which where build with 0 exp points reached normally the threshold and showed epx. level 3 (that's was fine so far), the ships build on the system with training facility reached 3700 exp point, then 4000 and also had epx. level 3 (fine again).
On the next turn, they all stayed at 4000 exp. points but gain exp. level 4.
I could not found the failure within my new code so I explain it that way:
When the new turn starts the crew exp. bonus is added, second the new crew exp. code will be executed, and after this the new training limit code is executed.

@Spocks-cuddly-tribble:
Could you confirm the code order?
It is possible to rearrange the order so first training limit is checked, then crew exp. boni will be calculated?

BTW: New code has only 2 unused bytes till next code, so there is no space for code extention.

<<<edit>>>

new code is:

Code: Select all

0x070100:
		5152 8B48 4051 5A81 F900 0300 007D 0CC7
		4044 0000 0000 C1EA 07EB 5781 F900 0800
		007D 14C7 4044 0100 0000 81EA 0001 0000
		C1EA 0842 42EB 3B81 F900 1200 007D 15C7
		4044 0200 0000 81EA 0002 0000 C1EA 0983
		C206 EB1E C1EA 0A83 C20B 81F9 0020 0000
		7D09 C740 4403 0000 00EB 07C7 4044 0400
		0000 8950 2C89 5030 8950 345A 59C3 9090
in assembler it looks:

Code: Select all

51                 push    ecx
52                 push    edx
8B4840             mov     ecx, [eax+40h]
51                 push    ecx
5A                 pop     edx
81F900030000       cmp     ecx, 300h
; exp points <768>= 128: +1; >=256: +2; >=384: +3; >=512: +4; >=640: +5
EB57               jmp     short loc_470D72
81F900080000       cmp     ecx, 800h
; exp points <2048>=768: +6; >=1024: +7; >=1280: +8; >=1536: +9; >=1792: +10
EB3B               jmp     short loc_470D72
81F900120000       cmp     ecx, 1200h
; exp points <4608>=2048: +11; >=2560: +12; >=3072: +13; >=3584: +14; >=4096: +15
EB1E               jmp     short loc_470D72
C1EA0A             shr     edx, 0Ah
; edx = edx / 1024
83C20B             add     edx, 0Bh
; exp. points/boni >=5120: +16; >=6144: +17; >=7168: +18; >=8192: +19
; exp. points/boni >=9216: +20; >=10240: +21; >=11268: +22; ...; >=20096: +30; ...
81F900200000       cmp     ecx,  2000h
; exp points < 8192
7D09               jge     short loc_470D6B
C7404403000000     mov     dword ptr [eax+44h], 3
; exp level = 3 of 0-4
EB07               jmp     short loc_470D72
C7404404000000     mov     dword ptr [eax+44h], 4
; exp level = 4 of 0-4
89502C		   mov     [eax+2Ch], edx
895030             mov     [eax+30h], edx
895034             mov     [eax+34h], edx
5A                 pop     edx
59                 pop     ecx
C3                 retn
life long and prosper
User avatar
DOT
Lieutenant-Commander
Lieutenant-Commander
Posts: 100
Joined: Tue Dec 23, 2008 3:00 am
Location: 49°N, 8°E

Post by DOT »

The following are only interesting for DOT
Indeed it is... :wink:
Thank you very much!
B.) Race specific starting EPs for empires (replaces klingon bonus)

Code:
trek.exe at 0x45768
replace:
80 7D 4C 03 75 10 90 90 90 90 90 C7 84 24 C0 02 00 00 5E 01
with:
0F B6 45 4C 3C 04 7F 0E 8D 34 85 XX XX XX XX 89 B4 24 C0 02

(XX = asm!-address of your new emps_starting_EPs data field)

replacement at asm 446368:

movzx eax, byte ptr [ebp+4Ch]
cmp al, 4
jg short loc_44637E
lea esi, ds:emps_starting_EPs[eax*4]
mov [esp+2C0h], esi
There is a little bug inside: Chaning

Code: Select all

lea     esi, ds:emps_starting_EPs[eax*4]
to

Code: Select all

mov     esi, ds:emps_starting_EPs[eax*4]
makes the code working as intended.
Spocks-cuddly-tribble wrote:That's bollocks, and you should know it -> google -> mov / lea

This is the 4th time that this guy is claiming his screw up was caused by my (faulty) code. Don't trust his lies. He is a romulan agitator as it seems... Just kidding, it's good to have you all here.

When I first took the code unchanged - in combination with the extended terraforming values code change (and using the former colonizing table as empire specific crew exp value table) - my first build ship - a colony ship -ended up with over 5,500,000 exp points ... 8O 8O
Spocks-cuddly-tribble wrote:I remember your "extended terraforming values". At least the starting pop formula is questionable:
Gowron wrote:note that this should always be a multiple of 10(dec), otherwise auto-assigning workers to buildings (when the system grows) will be bugged.
Also you should at least give/explain your calculation formulae (f.e. +20/8 rounded down...) for those who are interested to use your mod (people who understand assembler code don't need it after reading basic topics i.e. "Colonies: population, farms, factories" & "instant terraforming bug fix").
DOT wrote:This should simulate tuning problems when more than one colony ship crew works together while terraforming of one planet.
Unless you prevent simultaneous terraforming by multiple taskforces - pointless.
life long and prosper
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 876
Joined: Sun Apr 27, 2008 2:00 am

Post by Spocks-cuddly-tribble »

DOT wrote:
The following are only interesting for DOT
Indeed it is... :wink:
Thank you very much!
B.) Race specific starting EPs for empires (replaces klingon bonus)

Code:
trek.exe at 0x45768
replace:
80 7D 4C 03 75 10 90 90 90 90 90 C7 84 24 C0 02 00 00 5E 01
with:
0F B6 45 4C 3C 04 7F 0E 8D 34 85 XX XX XX XX 89 B4 24 C0 02

(XX = asm!-address of your new emps_starting_EPs data field)

replacement at asm 446368:

movzx eax, byte ptr [ebp+4Ch]
cmp al, 4
jg short loc_44637E
lea esi, ds:emps_starting_EPs[eax*4]
mov [esp+2C0h], esi
There is a little bug inside: Chaning

Code: Select all

lea     esi, ds:emps_starting_EPs[eax*4]
to

Code: Select all

mov     esi, ds:emps_starting_EPs[eax*4]
makes the code working as intended.
Spocks-cuddly-tribble wrote:That's bollocks, and you should know it -> google -> mov / lea

This is the 4th time that this guy is claiming his screw up was caused by my (faulty) code. Don't trust his lies. He is a romulan agitator as it seems... Just kidding, it's good to have you all here.

When I first took the code unchanged - in combination with the extended terraforming values code change (and using the former colonizing table as empire specific crew exp value table) - my first build ship - a colony ship -ended up with over 5,500,000 exp points ... 8O 8O
The assembly guide with the recommendation is offline now (maybe was wrong/ unclear at this point). So we use "move" to be on the save side. I don't 100% remember, maybe I posted the wrong of my test codes. If so then I'm sorry. :?
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 “Modding Information Archive”