From 3f07cd95f7459e4e0515a60d34b47b91db2d2117 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 29 Apr 2013 21:19:42 -0400 Subject: [PATCH] GetItemAttr and related fns --- main.asm | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- wram.asm | 7 +++- 2 files changed, 113 insertions(+), 4 deletions(-) diff --git a/main.asm b/main.asm index eed5ca1b1..4c9f7be64 100644 --- a/main.asm +++ b/main.asm @@ -5451,20 +5451,124 @@ GetTMHMNumber: ; d407 jr c, .done cp $dc ; TM28-29 jr c, .skip + dec a .skip dec a .done - sub TM_01 - inc a ld c, a ret ; d417 -INCBIN "baserom.gbc", $d417, $fa0b - $d417 +GetNumberedTMHM: ; d417 +; Return the item id of a TM/HM by number c. + + ld a, c + +; Skip any gaps. + cp 5 + jr c, .done + cp 29 + jr c, .skip + + inc a +.skip + inc a +.done + add TM_01 + dec a + ld c, a + ret +; d427 + + +CheckTossableItem: ; d427 +; Return 1 in $d142 and carry if CurItem can't be removed from the bag. + ld a, 4 + call GetItemAttr + bit 7, a + jr nz, Function0xd47f + and a + ret +; d432 + +CheckSelectableItem: ; d432 +; Return 1 in $d142 and carry if CurItem can't be selected. + ld a, 4 + call GetItemAttr + bit 6, a + jr nz, Function0xd47f + and a + ret +; d43d + +CheckItemPocket: ; d43d +; Return the pocket for CurItem in $d142. + ld a, 5 + call GetItemAttr + and $f + ld [$d142], a + ret +; d448 + +CheckItemContext: ; d448 +; Return the context for CurItem in $d142. + ld a, 6 + call GetItemAttr + and $f + ld [$d142], a + ret +; d453 + +CheckItemMenu: ; d453 +; Return the menu for CurItem in $d142. + ld a, 6 + call GetItemAttr + swap a + and $f + ld [$d142], a + ret +; d460 + +GetItemAttr: ; d460 +; Get attribute a of CurItem. + + push hl + push bc + + ld hl, $67c1 ; Items + ld c, a + ld b, 0 + add hl, bc + + xor a + ld [$d142], a + + ld a, [CurItem] + dec a + ld c, a + ld a, 7 + call AddNTimes + ld a, $1 ; BANK(Items) + call GetFarByte + + pop bc + pop hl + ret +; d47f + +Function0xd47f: ; d47f + ld a, 1 + ld [$d142], a + scf + ret +; d486 + + +INCBIN "baserom.gbc", $d486, $fa0b - $d486 SECTION "bank4",DATA,BANK[$4] diff --git a/wram.asm b/wram.asm index 713b16393..de76fe74f 100644 --- a/wram.asm +++ b/wram.asm @@ -918,7 +918,12 @@ VramState: ; d0ed ; flickers when climbing waterfall ds 1 - ds 26 + ds 24 + +CurItem: ; d106 + ds 1 + + ds 1 CurPartySpecies: ; d108 ds 1