It is currently 28 Apr 2024, 03:44
   
Text Size

ASM question

Discuss Upcoming Releases, Coding New Cards, Etc.
PLEASE DO NOT REPORT BUGS HERE!

Moderators: BAgate, drool66, Aswan jaguar, gmzombie, stassy, CCGHQ Admins

ASM question

Postby jatill » 04 Mar 2009, 18:06

I notice that in certain cards (Jaymadea Tome, Fountain of Youth, etc) there is a section for op code 6C. Can anyone explain what's going on here?

00428657 837D106C cmp dword ptr [ebp+$10], $6c
0042865B 7566 jnz +$66 ($4286c3)
0042865D 8B0D8C397A00 mov ecx, [$7a398c]
00428663 394D0C cmp [ebp+$c], ecx
00428666 755B jnz +$5b ($4286c3)
00428668 A1848C7300 mov eax, [$738c84]
0042866D 394508 cmp [ebp+8], eax
00428670 7551 jnz +$51 ($4286c3)
00428672 A14C687300 mov eax, [$73684c]
00428677 394508 cmp [ebp+8], eax
0042867A 7547 jnz +$47 ($4286c3)
0042867C F6054006790002 test byte ptr [$790640], 2
00428683 753E jnz +$3e ($4286c3)
00428685 E8F693FDFF call -$26c0a ($401a80)
0042868A 8B4508 mov eax, [ebp+8]
0042868D 50 push eax
0042868E 8B466C mov eax, [esi+$6c]
00428691 50 push eax
00428692 8B4508 mov eax, [ebp+8]
00428695 50 push eax
00428696 E8B547FFFF call -$b84b ($41ce50)
0042869B 83C40C add esp, $c
0042869E 8945FC mov [ebp-4], eax
004286A1 85C0 test eax, eax
004286A3 741E jz +$1e ($4286c3)
004286A5 A14C687300 mov eax, [$73684c]
004286AA C1E005 shl eax, 5
004286AD 8B807CF44E00 mov eax, [eax+$4ef47c]
004286B3 99 cdq
004286B4 F77DFC idiv dword ptr [ebp-4]
004286B7 83F804 cmp eax, 4
004286BA 7C07 jl +7 ($4286c3)
004286BC 8305A8317A0030 add dword ptr [$7a31a8], $30
jatill
DEVELOPER
 
Posts: 2118
Joined: 24 Feb 2009, 16:35
Has thanked: 5 times
Been thanked: 17 times

Re: ASM question

Postby jatill » 04 Mar 2009, 19:08

I remove that code and the card works, as far as I can tell. Maybe there are edge cases it handles.

In any case, my true question is this: how does a card know if it has already been activated? For example, if I have 8 mana available, and I activate Jaymadae Tome, and then activate it again in response, the game doesn't let me play 8 mana and draw 2 cards. I can't figure out what is stopping me from doing this.

If I create a proc that calls tome and try clicking the tome twice, THEN it asks me to pay twice. Weird, right?
jatill
DEVELOPER
 
Posts: 2118
Joined: 24 Feb 2009, 16:35
Has thanked: 5 times
Been thanked: 17 times

Re: ASM question

Postby HarryPitfall » 04 Mar 2009, 21:27

I also notice some 'eventcodes' that it's appear nonused, or used by AI (maybe).
In case of tome, you can't activate multiple times, 'cause of self status, like this, more or less, is how the card works:

Case EventCode Of
EVENT_CANACTIVATE: Result := Player.HaveManaAvaiable(4, AnyColor) And Not(Card.IsTapped);
EVENT_PAYACTIVATECOST: Begin
Player.PayMana(4, AnyColor);
Card.IsTapped := True;
End;
EVENT_RESOLVEABILITY: Player.DrawCards(1);
End;

After the cost is paid, the status of card prevent to reactivate on the correct event.

In some cases, the AI call EVENT_CANACTIVATE, then, EVENT_PAYACTIVATECOST, then, call EVENT_RESOLVEABILITY lots of times (see orcist spy)... maybe, some event, (like $6c), it's used to control some behavior about this...
HarryPitfall
AI Programmer
 
Posts: 175
Joined: 31 May 2008, 00:14
Has thanked: 1 time
Been thanked: 3 times

Re: ASM question

Postby 0rion79 » 05 Mar 2009, 06:56

Maybe I'm taking nonsense, but can this part of the code be used to fixt that random little problem with Nuisance Engine (and wall of kelp) and Orcish Spy?
User avatar
0rion79
 
Posts: 1520
Joined: 24 Feb 2009, 18:33
Location: Italy
Has thanked: 94 times
Been thanked: 61 times

Re: ASM question

Postby jatill » 05 Mar 2009, 18:02

So here's the really weird thing.

Try clicking Jay Tome a few times, and then cancel. All the prompts go away.

Now import the patch with the code somewhere else. Now when you cancel, you have to cancel each one. I wonder if there is some internal code somewhere that knows when to 'cancel all'.
jatill
DEVELOPER
 
Posts: 2118
Joined: 24 Feb 2009, 16:35
Has thanked: 5 times
Been thanked: 17 times


Return to Development

Who is online

Users browsing this forum: No registered users and 26 guests


Who is online

In total there are 26 users online :: 0 registered, 0 hidden and 26 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 26 guests

Login Form