summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxCrystal <rgr.crystal@gmail.com>2018-03-03 21:44:22 +0100
committerxCrystal <rgr.crystal@gmail.com>2018-03-03 21:44:22 +0100
commit4ce5374e962cea37d5e0834ab2488eef04cf13cf (patch)
tree32d9a0b3b5969541e460c5429aab23e7eabc1388 /src
parent96735ba758a5f91eccce9a654d8dab3879b9104a (diff)
More duel engine and menus disasm
Diffstat (limited to 'src')
-rw-r--r--src/engine/bank1.asm189
-rw-r--r--src/engine/home.asm108
-rw-r--r--src/text/text1.asm12
-rw-r--r--src/text/text2.asm4
-rw-r--r--src/text/text_offsets.asm16
-rw-r--r--src/wram.asm33
6 files changed, 290 insertions, 72 deletions
diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm
index 14a4e09..21d6eb1 100644
--- a/src/engine/bank1.asm
+++ b/src/engine/bank1.asm
@@ -191,7 +191,7 @@ StartDuel: ; 409f (1:409f)
jr z, .active_duelist_lost_batte
ld a, $5f
ld c, MUSIC_DARK_DIDDLY
- ldtx hl, DuelWasDrawText
+ ldtx hl, DuelWasADrawText
jr .handle_duel_finished
.active_duelist_won_battle
@@ -436,25 +436,25 @@ DuelMenuShortcut_PlayerDiscardPile: ; 4320 (1:4320)
jp c, PrintDuelMenu
jp DuelMainInterface
-; draw the opponent's play area interface
+; draw the opponent's play area screen
OpenOpponentPlayAreaScreen: ; 4329 (1:4329)
call SwapTurn
call OpenPlayAreaScreen
call SwapTurn
ret
-; draw the turn holder's play area interface
+; draw the turn holder's play area screen
OpenPlayAreaScreen: ; 4333 (1:4333)
call HasAlivePokemonInPlayArea
jp OpenPlayAreaScreenForViewing
-; draw the opponent's discard pile interface
+; draw the opponent's discard pile screen
OpenOpponentDiscardPileScreen: ; 4339 (1:4339)
call SwapTurn
call OpenDiscardPileScreen
jp SwapTurn
-; draw the player's discard pile interface
+; draw the player's discard pile screen
OpenPlayerDiscardPileScreen: ; 4342 (1:4342)
jp OpenDiscardPileScreen
@@ -467,10 +467,10 @@ Func_4345: ; 4345 (1:4345)
Func_434e: ; 434e (1:434e)
call CreateHandCardList
jr c, .no_cards_in_hand
- call Func_559a
+ call DrawCardListScreenLayout
ld a, START + A_BUTTON
ld [wcbd6], a
- jp $55f0
+ jp Func_55f0
.no_cards_in_hand
ldtx hl, NoCardsInHandText
jp DrawWideTextBox_WaitForInput
@@ -590,13 +590,13 @@ DuelMenu_Hand: ; 4425 (1:4425)
Func_4436: ; 4436 (1:4436)
call CreateHandCardList
- call Func_559a
- ld hl, $00aa
- call Func_5588
+ call DrawCardListScreenLayout
+ ldtx hl, PleaseSelectHandText
+ call SetCardListInfoBoxText
ld a, $1
ld [wcbde], a
.asm_4447
- call $55f0
+ call Func_55f0
push af
ld a, [wcbdf]
or a
@@ -669,7 +669,7 @@ UseEnergyCard: ; 4477 (1:4477)
.asm_44d2
call CreateHandCardList
- call Func_559a.asm_55be
+ call DrawCardListScreenLayout.draw
jp Func_4436.asm_4447
; 0x44db
@@ -1314,13 +1314,13 @@ Func_4b2c: ; 4b2c (1:4b2c)
Func_4b38: ; 4b38 (1:4b38)
ld a, [wDuelTempList]
- cp -1
+ cp $ff
ret z
- call Func_559a
+ call DrawCardListScreenLayout
call CountCardsInDuelTempList
ld hl, $5710
ld de, $0
- call $2799
+ call Func_2799
ldtx hl, TheCardYouReceivedText
lb de, 1, 1
call Func_22ae
@@ -1638,14 +1638,15 @@ DrawDuelMainScene: ; 4f9d (1:4f9d)
INCROM $503a, $5550
+; draw the turn holder's discard pile screen
OpenDiscardPileScreen: ; 5550 (1:5550)
call CreateDiscardPileCardList
jr c, .discard_pile_empty
- call Func_559a
- call Func_556d
+ call DrawCardListScreenLayout
+ call SetDiscardPileScreenTexts
ld a, START + A_BUTTON
ld [wcbd6], a
- call $55f0
+ call Func_55f0
or a
ret
.discard_pile_empty
@@ -1655,41 +1656,47 @@ OpenDiscardPileScreen: ; 5550 (1:5550)
ret
; 0x556d
-Func_556d: ; 556d (1:556d)
- ld de, $217
+; set wCardListHeaderText and SetCardListInfoBoxText to the text
+; that correspond to the Discard Pile screen
+SetDiscardPileScreenTexts: ; 556d (1:556d)
+ ldtx de, YourDiscardPileText
ldh a, [hWhoseTurn]
cp PLAYER_TURN
- jr z, .asm_5579
- ld de, $218
-.asm_5579
- ld hl, $56
- call Func_5580
+ jr z, .got_header_text
+ ldtx de, OpponentsDiscardPileText
+.got_header_text
+ ldtx hl, ChooseTheCardYouWishToExamineText
+ call SetCardListHeaderText
ret
; 0x5580
-Func_5580: ; 5580 (1:5580)
+SetCardListHeaderText: ; 5580 (1:5580)
ld a, e
- ld [wcbdc], a
+ ld [wCardListHeaderText], a
ld a, d
- ld [wcbdd], a
+ ld [wCardListHeaderText + 1], a
; fallthrough
-Func_5588: ; 5588 (1:5588)
+SetCardListInfoBoxText: ; 5588 (1:5588)
ld a, l
- ld [wcbda], a
+ ld [wCardListInfoBoxText], a
ld a, h
- ld [wcbdb], a
+ ld [wCardListInfoBoxText + 1], a
ret
; 0x5591
Func_5591: ; 5591 (1:5591)
- call Func_559a
+ call DrawCardListScreenLayout
ld a, $02
ld [wcbde], a
ret
; 0x559a
-Func_559a: ; 559a (1:559a)
+; draw the layout of the screen that displays the player's Hand card list or a
+; Discard Pile card list, including a bottom-right image of the current card.
+; since this loads the text for the Hand card list screen, SetDiscardPileScreenTexts
+; is called after this if the screen corresponds to a Discard Pile list.
+DrawCardListScreenLayout: ; 559a (1:559a)
xor a
ld hl, wSelectedDuelSubMenuItem
ld [hli], a
@@ -1701,29 +1708,31 @@ Func_559a: ; 559a (1:559a)
ld [wcbde], a
ld a, START
ld [wcbd6], a
- ld hl, wcbda
- ld [hl], $aa
- inc hl
- ld [hl], $00
+ ld hl, wCardListInfoBoxText
+ ld [hl], LOW(PleaseSelectHandText_)
inc hl
- ld [hl], $a7
+ ld [hl], HIGH(PleaseSelectHandText_)
+ inc hl ; wCardListHeaderText
+ ld [hl], LOW(DuelistsHandText_)
inc hl
- ld [hl], $00
-.asm_55be
+ ld [hl], HIGH(DuelistsHandText_)
+.draw
call ZeroObjectPositionsAndToggleOAMCopy
call EmptyScreen
call LoadDuelHUDTiles
call LoadDuelCardSymbolTiles
+ ; draw the surrounding box
lb de, 0, 0
lb bc, 20, 13
call DrawRegularTextBox
+ ; draw the image of the selected card
ld a, $a0
lb hl, 6, 1
lb de, 12, 12
lb bc, 8, 6
call FillRectangle
call ApplyBGP6OrSGB3ToCardImage
- call $5744
+ call Func_5744
ld a, [wDuelTempList]
cp $ff
scf
@@ -1732,7 +1741,103 @@ Func_559a: ; 559a (1:559a)
ret
; 0x55f0
- INCROM $55f0, $576a
+Func_55f0: ; 55f0 (1:55f0)
+ call DrawNarrowTextBox
+ call $56a0
+.asm_55f6
+ call CountCardsInDuelTempList
+ ld hl, wSelectedDuelSubMenuItem
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld hl, $5710
+ call Func_2799
+ call Func_58aa
+ call EnableLCD
+.asm_560b
+ call DoFrame
+ call $5690
+ call Func_2626
+ jr nc, .asm_560b
+ ld hl, wSelectedDuelSubMenuItem
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ ldh a, [hButtonsPressed]
+ ld b, a
+ bit SELECT_F, b
+ jr nz, .asm_563b
+ bit B_BUTTON_F, b
+ jr nz, .asm_568c
+ ld a, [wcbd6]
+ and b
+ jr nz, .asm_5654
+ ldh a, [hCurrentMenuItem]
+ call GetCardInDuelTempList_OnlyDeckIndex
+ call $56c2
+ jr c, Func_55f0
+ ldh a, [hTempCardIndex_ff98]
+ or a
+ ret
+.asm_563b
+ ld a, [wcbdf]
+ or a
+ jr nz, .asm_560b
+ call SortCardsInDuelTempListByID
+ xor a
+ ld hl, wSelectedDuelSubMenuItem
+ ld [hli], a
+ ld [hl], a
+ ld a, $01
+ ld [wcbdf], a
+ call EraseCursor
+ jr .asm_55f6
+.asm_5654
+ ldh a, [hCurrentMenuItem]
+ call GetCardInDuelTempList
+ call LoadCardDataToBuffer1_FromDeckIndex
+ call $5762
+ ldh a, [hButtonsPressed2]
+ bit D_UP_F, a
+ jr nz, .asm_566f
+ bit D_DOWN_F, a
+ jr nz, .asm_5677
+ call DrawCardListScreenLayout.draw
+ jp Func_55f0
+.asm_566f
+ ldh a, [hCurrentMenuItem]
+ or a
+ jr z, .asm_5654
+ dec a
+ jr .asm_5681
+.asm_5677
+ call CountCardsInDuelTempList
+ ld b, a
+ ldh a, [hCurrentMenuItem]
+ inc a
+ cp b
+ jr nc, .asm_5654
+.asm_5681
+ ldh [hCurrentMenuItem], a
+ ld hl, wSelectedDuelSubMenuItem
+ ld [hl], $00
+ inc hl
+ ld [hl], a
+ jr .asm_5654
+.asm_568c
+ ldh a, [hCurrentMenuItem]
+ scf
+ ret
+; 0x5690
+
+ INCROM $5690, $5744
+
+Func_5744: ; 5744 (1:5744)
+ ld hl, wcbd8
+ jp CallIndirect
+; 0x574a
+
+ INCROM $574a, $576a
Func_576a: ; 576a (1:576a)
ld a, B_BUTTON
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 454e83b..91ef164 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -6428,7 +6428,19 @@ Func_256d: ; 256d (0:256d)
ret
; 0x2589
- INCROM $2589, $2636
+ INCROM $2589, $2626
+
+Func_2626: ; 2626 (0:2626)
+ call HandleMenuInput
+ ret nc
+ ld a, [wcd19]
+ ld d, a
+ ld a, [wCurMenuItem]
+ ld e, a
+ ldh a, [hCurrentMenuItem]
+ scf
+ ret
+; 0x2636
; initializes cursor parameters given the 8 bytes starting at hl,
; which represent the following:
@@ -6657,7 +6669,7 @@ HandleDuelMenuInput: ; 271a (0:271a)
add a
ld c, a
ld b, $0
- ld hl, $278d
+ ld hl, DuelMenuCursorCoords
add hl, bc
ld b, [hl]
inc hl
@@ -6670,7 +6682,97 @@ HandleDuelMenuInput: ; 271a (0:271a)
ret
; 0x278d
- INCROM $278d, $2988
+DuelMenuCursorCoords: ; 278d (0:278d)
+ db 2, 14 ; Hand
+ db 2, 16 ; Attack
+ db 8, 14 ; Check
+ db 8, 16 ; Pkmn Power
+ db 14, 14 ; Retreat
+ db 14, 16 ; Done
+
+Func_2799: ; 2799 (0:2799)
+ call $25ea
+ ld hl, wMenuFunctionPointer
+ ld a, LOW($283f)
+ ld [hli], a
+ ld a, HIGH($283f)
+ ld [hli], a
+ ld a, 2
+ ld [wYDisplacementBetweenMenuItems], a
+ ld a, $01
+ ld [wcd97], a
+ ld e, $00
+ ld a, [wcd19]
+ or a
+ jr z, .asm_27b9
+ ld e, $0c
+.asm_27b9
+ ld a, [wCursorYPosition]
+ dec a
+ ld c, a
+ ld b, $12
+ ld a, e
+ call Func_06c3
+ ld e, $00
+ ld a, [wcd19]
+ ld hl, wNumMenuItems
+ add [hl]
+ ld hl, wcd1b
+ cp [hl]
+ jr nc, .asm_27d5
+ ld e, $2f
+.asm_27d5
+ ld a, [wNumMenuItems]
+ add a
+ add c
+ dec a
+ ld c, a
+ ld a, e
+ call Func_06c3
+ ld a, [wcd19]
+ ld e, a
+ ld d, $00
+ ld hl, wDuelTempList
+ add hl, de
+ ld a, [wNumMenuItems]
+ ld b, a
+ ld a, [wcd1a]
+ ld d, a
+ ld a, [wCursorYPosition]
+ ld e, a
+ ld c, $00
+.asm_27f8
+ ld a, [hl]
+ cp $ff
+ jr z, .asm_2826
+ push hl
+ push bc
+ push de
+ call LoadCardDataToBuffer1_FromDeckIndex
+ call DrawCardSymbol
+ call Func_22ae
+ ld a, [wcd1c]
+ call Func_29f5
+ ld hl, wDefaultText
+ call Func_21c5
+ pop de
+ pop bc
+ pop hl
+ inc hl
+ ld a, [wcd1b]
+ dec a
+ inc c
+ cp c
+ jr c, .asm_2826
+ inc e
+ inc e
+ dec b
+ jr nz, .asm_27f8
+.asm_2826
+ ret
+; 0x2827
+
+ INCROM $2827, $2988
CardTypeToSymbolID: ; 2988 (0:2988)
ld a, [wLoadedCard1Type]
diff --git a/src/text/text1.asm b/src/text/text1.asm
index df9c6b3..f08651f 100644
--- a/src/text/text1.asm
+++ b/src/text/text1.asm
@@ -367,7 +367,7 @@ TransmissionErrorText: ; 36947 (d:6947)
line "Start again from the beginning."
done
-Text0056: ; 3697c (d:697c)
+ChooseTheCardYouWishToExamineText: ; 3697c (d:697c)
text "Choose the card"
line "you wish to examine."
done
@@ -524,7 +524,7 @@ DecisionText: ; 36da4 (d:6da4)
text "Decision..."
done
-DuelWasDrawText: ; 36db1 (d:6db1)
+DuelWasADrawText: ; 36db1 (d:6db1)
text "The Duel with ", TX_RAM1, ""
line "was a Draw!"
done
@@ -779,19 +779,19 @@ Text00a6: ; 3737b (d:737b)
text "Player's Discard Pile"
done
-Text00a7: ; 37392 (d:7392)
+DuelistsHandText: ; 37392 (d:7392)
text TX_RAM1, "'s Hand"
done
-Text00a8: ; 3739c (d:739c)
+DuelistsPlayAreaText: ; 3739c (d:739c)
text TX_RAM1, "'s Play Area"
done
-Text00a9: ; 373ab (d:73ab)
+DuelistsDeckText: ; 373ab (d:73ab)
text TX_RAM1, "'s Deck"
done
-Text00aa: ; 373b5 (d:73b5)
+PleaseSelectHandText: ; 373b5 (d:73b5)
text "Please select"
line "Hand."
done
diff --git a/src/text/text2.asm b/src/text/text2.asm
index 1404520..e9666c7 100644
--- a/src/text/text2.asm
+++ b/src/text/text2.asm
@@ -1498,11 +1498,11 @@ Text0216: ; 3b7b9 (e:77b9)
db $03,$7b
done
-Text0217: ; 3b7bc (e:77bc)
+YourDiscardPileText: ; 3b7bc (e:77bc)
text "Your Discard Pile"
done
-Text0218: ; 3b7cf (e:77cf)
+OpponentsDiscardPileText: ; 3b7cf (e:77cf)
text "Opponent's Discard Pile"
done
diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm
index a93e69e..20f1339 100644
--- a/src/text/text_offsets.asm
+++ b/src/text/text_offsets.asm
@@ -87,7 +87,7 @@ TextOffsets:: ; 34000 (d:4000)
textpointer YouPlayFirstText ; 0x0053
textpointer YouPlaySecondText ; 0x0054
textpointer TransmissionErrorText ; 0x0055
- textpointer Text0056 ; 0x0056
+ textpointer ChooseTheCardYouWishToExamineText ; 0x0056
textpointer TransmitingDataText ; 0x0057
textpointer Text0058 ; 0x0058
textpointer Text0059 ; 0x0059
@@ -120,7 +120,7 @@ TextOffsets:: ; 34000 (d:4000)
textpointer IfHeadPlayerPlaysFirstText ; 0x0074
textpointer CoinTossToDetermineWhoFirstText ; 0x0075
textpointer DecisionText ; 0x0076
- textpointer DuelWasDrawText ; 0x0077
+ textpointer DuelWasADrawText ; 0x0077
textpointer WonDuelText ; 0x0078
textpointer LostDuelText ; 0x0079
textpointer StartSuddenDeathMatchText ; 0x007a
@@ -168,10 +168,10 @@ TextOffsets:: ; 34000 (d:4000)
textpointer NoCardsInHandText ; 0x00a4
textpointer TheDiscardPileHasNoCardsText ; 0x00a5
textpointer Text00a6 ; 0x00a6
- textpointer Text00a7 ; 0x00a7
- textpointer Text00a8 ; 0x00a8
- textpointer Text00a9 ; 0x00a9
- textpointer Text00aa ; 0x00aa
+ textpointer DuelistsHandText ; 0x00a7
+ textpointer DuelistsPlayAreaText ; 0x00a8
+ textpointer DuelistsDeckText ; 0x00a9
+ textpointer PleaseSelectHandText ; 0x00aa
textpointer Text00ab ; 0x00ab
textpointer Text00ac ; 0x00ac
textpointer Text00ad ; 0x00ad
@@ -536,8 +536,8 @@ TextOffsets:: ; 34000 (d:4000)
textpointer Text0214 ; 0x0214
textpointer Text0215 ; 0x0215
textpointer Text0216 ; 0x0216
- textpointer Text0217 ; 0x0217
- textpointer Text0218 ; 0x0218
+ textpointer YourDiscardPileText ; 0x0217
+ textpointer OpponentsDiscardPileText ; 0x0218
textpointer Text0219 ; 0x0219
textpointer Text021a ; 0x021a
textpointer Text021b ; 0x021b
diff --git a/src/wram.asm b/src/wram.asm
index 226248b..79c94c5 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -570,17 +570,13 @@ wcbd8:: ; cbd8
wcbd9:: ; cbd9
ds $1
-wcbda:: ; cbda
- ds $1
-
-wcbdb:: ; cbdb
- ds $1
-
-wcbdc:: ; cbdc
- ds $1
+; in the hand or discard pile card screen, id of the text printed in the bottom-left box
+wCardListInfoBoxText:: ; cbda
+ ds $2
-wcbdd:: ; cbdd
- ds $1
+; in the hand or discard pile card screen, id of the text printed as the header title
+wCardListHeaderText:: ; cbdc
+ ds $2
wcbde:: ; cbde
ds $1
@@ -882,7 +878,22 @@ wTileBehindCursor:: ; cd16
wMenuFunctionPointer:: ; cd17
ds $2
- ds $7f
+wcd19:: ; cd19
+ ds $1
+
+wcd1a:: ; cd1a
+ ds $1
+
+wcd1b:: ; cd1b
+ ds $1
+
+wcd1c:: ; cd1c
+ ds $1
+
+ ds $7a
+
+wcd97:: ; cd97
+ ds $1
; x coord of the leftmost item in a horizontal menu
wLeftmostItemCursorX:: ; cd98