; Cactus Kev / Treys prime-product ranking, with the library's exact tie breakers. LookupPokerFive3D PROC uses ebx esi edi hand:DWORD local product:DWORD,suit:DWORD,flush:DWORD,lo:DWORD,hi:DWORD cmp cardRanks3D, 0 je poker_rank_invalid mov product, 1 mov suit, -1 mov flush, 1 mov esi, hand mov edi, 5 poker_rank_card: mov eax, [esi] xor edx, edx mov ecx, 13 div ecx cmp suit, -1 jne @F mov suit, eax @@: cmp eax, suit je @F mov flush, 0 @@: mov eax, cardPrimes3D[edx*4] imul eax, product mov product, eax add esi, 4 dec edi jnz poker_rank_card mov esi, cardRanks3D mov lo, 0 mov hi, 1287 cmp flush, 1 je poker_rank_search add esi, 1287 * 8 mov hi, 6175 poker_rank_search: mov eax, lo cmp eax, hi jae poker_rank_invalid add eax, hi shr eax, 1 mov ebx, eax mov edx, [esi+eax*8] cmp edx, product je poker_rank_found ja poker_rank_lower inc eax mov lo, eax jmp poker_rank_search poker_rank_lower: mov hi, eax jmp poker_rank_search poker_rank_found: mov eax, [esi+ebx*8+4] ret poker_rank_invalid: mov eax, 7463 ret LookupPokerFive3D ENDP EvaluateNativePoker3D PROC uses ebx esi edi hand:DWORD,count:DWORD local five[20]:BYTE, seenLo:DWORD,seenHi:DWORD,best:DWORD,a:DWORD,b:DWORD,idxC:DWORD,d:DWORD,e:DWORD cmp count, 5 jb native_rank_invalid cmp count, 7 ja native_rank_invalid mov seenLo, 0 mov seenHi, 0 mov esi, hand mov ecx, count native_rank_validate: mov eax, [esi] cmp eax, 52 jae native_rank_invalid cmp eax, 32 jb @F sub eax, 32 bts seenHi, eax jc native_rank_invalid jmp native_rank_next @@: bts seenLo, eax jc native_rank_invalid native_rank_next: add esi, 4 dec ecx jnz native_rank_validate mov best, 7463 mov a, 0 native_rank_a: mov eax, a inc eax mov b, eax native_rank_b: mov eax, b inc eax mov idxC, eax native_rank_c: mov eax, idxC inc eax mov d, eax native_rank_d: mov eax, d inc eax mov e, eax native_rank_e: mov esi, hand mov ecx, a mov eax, [esi+ecx*4] mov DWORD PTR five[0], eax mov ecx, b mov eax, [esi+ecx*4] mov DWORD PTR five[4], eax mov ecx, idxC mov eax, [esi+ecx*4] mov DWORD PTR five[8], eax mov ecx, d mov eax, [esi+ecx*4] mov DWORD PTR five[12], eax mov ecx, e mov eax, [esi+ecx*4] mov DWORD PTR five[16], eax invoke LookupPokerFive3D, ADDR five cmp eax, best jae @F mov best, eax @@: inc e mov eax, e cmp eax, count jb native_rank_e inc d mov eax, count dec eax cmp d, eax jb native_rank_d inc idxC dec eax cmp idxC, eax jb native_rank_c inc b dec eax cmp b, eax jb native_rank_b inc a dec eax cmp a, eax jb native_rank_a mov eax, best ret native_rank_invalid: mov eax, 7463 ret EvaluateNativePoker3D ENDP NativePokerClass3D PROC score:DWORD xor eax, eax mov edx, score mov ecx, 1 native_rank_class: cmp edx, pkRankLimits3D[ecx*4] ja native_rank_class_done mov eax, ecx inc ecx cmp ecx, 9 jb native_rank_class native_rank_class_done: ret NativePokerClass3D ENDP