diff options
author | ElectroDeoxys <ElectroDeoxys@gmail.com> | 2019-07-20 17:01:14 +0100 |
---|---|---|
committer | ElectroDeoxys <ElectroDeoxys@gmail.com> | 2019-08-07 23:24:59 +0100 |
commit | f233f4a16f96546652df03660a4f0f2c6ffdc8c0 (patch) | |
tree | 22da47840a93512306f6a733768cc5bb3c27ea95 /src | |
parent | 858e280a590d5d607a31a2e0a3c8dfecfae26d6f (diff) |
Label SortTempHandByList
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/bank05.asm | 78 | ||||
-rw-r--r-- | src/wram.asm | 10 |
2 files changed, 83 insertions, 5 deletions
diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index fca1b47..2da9ce7 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -259,7 +259,26 @@ Func_1468b: ; 1468b (5:468b) ret ; 0x14786 - INCROM $14786, $15636 + INCROM $14786, $1514f + +; these seem to be lists of card IDs +; for the AI to look up in their hand +Data_1514f: ; 1514f (5:514f) + db KANGASKHAN + db CHANSEY + db SNORLAX + db MR_MIME + db ABRA + db $00 + + db ABRA + db MR_MIME + db KANGASKHAN + db SNORLAX + db CHANSEY + db $00 + + INCROM $1515b, $15636 Func_15636: ; 15636 (5:5636) ld a, $10 @@ -373,7 +392,7 @@ Func_15ea6 ; 15ea6 (5:5ea6) Func_15eae: ; 15eae (5:5eae) call CreateHandCardList - call Func_1633f + call SortTempHandByList ld hl, wDuelTempList ld de, $ceda call Func_15ea6 @@ -454,8 +473,59 @@ Func_15f4c ; 15f4c (5:5f4c) Func_161d5 ; 161d5 (5:61d5) INCROM $161d5, $1633f -Func_1633f ; 1633f (5:633f) - INCROM $1633f, $1637b +; Goes through $00 terminated list pointed +; by wcdae and compares it to each card in hand. +; Sorts the hand in wDuelTempList so that the found card IDs +; are in the same order as the list pointed by de. +SortTempHandByList: ; 1633f (5:633f) + ld a, [wcdaf] + or a + ret z + ld d, a + ld a, [wcdae] + ld e, a + ld c, $00 +.next_id + ld a, [de] + or a + ret z + inc de + ld hl, wDuelTempList + ld b, $00 + add hl, bc + + ld b, a +.next_card + ld a, [hl] + ldh [hTempCardIndex_ff98], a + cp $ff + jr z, .next_id + push bc + push de + call GetCardIDFromDeckIndex + ld a, e + pop de + pop bc + cp b + jr nz, .not_same + +; found + push bc + push hl + ld b, $00 + ld hl, wDuelTempList + add hl, bc + ld b, [hl] + ldh a, [hTempCardIndex_ff98] + ld [hl], a + pop hl + ld [hl], b + pop bc + inc c +.not_same + inc hl + jr .next_card +; 0x1637b Func_1637b ; 1637b (5:637b) INCROM $1637b, $163c9 diff --git a/src/wram.asm b/src/wram.asm index a2e01a2..8d742cb 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1184,7 +1184,15 @@ wcda6:: ; cda6 wcda7:: ; cda7 ds $1 - ds $33 + ds $6 + +; pointer to a list of card IDs for sorting AI hand +wcdae:: ; cdae + ds $1 +wcdaf:: ; cdaf + ds $1 + + ds $2b wcddb:: ; cddb ds $1 |