field moves

This commit is contained in:
YamaArashi 2015-07-14 15:48:34 -07:00
parent 01631a2e59
commit a0ed5bd4aa
4 changed files with 107 additions and 80 deletions

View file

@ -33,14 +33,14 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
ld a,FIELD_MOVE_MON_MENU ld a,FIELD_MOVE_MON_MENU
ld [wTextBoxID],a ld [wTextBoxID],a
call DisplayTextBoxID ; display pokemon menu options call DisplayTextBoxID ; display pokemon menu options
ld hl,wWhichTrade ld hl,wFieldMoves
ld bc,$020c ; max menu item ID, top menu item Y ld bc,$020c ; max menu item ID, top menu item Y
ld e,5 ld e,5
.adjustMenuVariablesLoop .adjustMenuVariablesLoop
dec e dec e
jr z,.storeMenuVariables jr z,.storeMenuVariables
ld a,[hli] ld a,[hli]
and a and a ; end of field moves?
jr z,.storeMenuVariables jr z,.storeMenuVariables
inc b inc b
dec c dec c
@ -50,7 +50,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
ld hl,wTopMenuItemY ld hl,wTopMenuItemY
ld a,c ld a,c
ld [hli],a ; top menu item Y ld [hli],a ; top menu item Y
ld a,[$fff7] ld a,[hFieldMoveMonMenuTopMenuItemX]
ld [hli],a ; top menu item X ld [hli],a ; top menu item X
xor a xor a
ld [hli],a ; current menu item ID ld [hli],a ; current menu item ID

View file

@ -161,5 +161,7 @@ H_WHOSETURN EQU $FFF3 ; 0 on players turn, 1 on enemys turn
; bit 1: menu is double spaced ; bit 1: menu is double spaced
hFlags_0xFFF6 EQU $FFF6 hFlags_0xFFF6 EQU $FFF6
hFieldMoveMonMenuTopMenuItemX EQU $FFF7
hJoyInput EQU $FFF8 hJoyInput EQU $FFF8

163
main.asm
View file

@ -1719,86 +1719,101 @@ TwoOptionMenuStrings: ; 7671 (1:7671)
.HealCancelMenu ; 76d5 (1:36d5) .HealCancelMenu ; 76d5 (1:36d5)
db "HEAL",$4E,"CANCEL@" db "HEAL",$4E,"CANCEL@"
DisplayFieldMoveMonMenu: ; 76e1 (1:36e1) DisplayFieldMoveMonMenu: ; 76e1 (1:76e1)
xor a xor a
ld hl, wWhichTrade ld hl, wFieldMoves
ld [hli], a ld [hli], a ; wFieldMoves
ld [hli], a ld [hli], a ; wFieldMoves + 1
ld [hli], a ld [hli], a ; wFieldMoves + 2
ld [hli], a ld [hli], a ; wFieldMoves + 3
ld [hli], a ld [hli], a ; wNumFieldMoves
ld [hl], $c ld [hl], 12 ; wFieldMovesLeftmostXCoord
call GetMonFieldMoves call GetMonFieldMoves
ld a, [wTrainerScreenX] ld a, [wNumFieldMoves]
and a and a
jr nz, .asm_770f jr nz, .fieldMovesExist
; no field moves
hlCoord 11, 11 hlCoord 11, 11
ld b, $5 ld b, 5
ld c, $7 ld c, 7
call TextBoxBorder call TextBoxBorder
call UpdateSprites call UpdateSprites
ld a, $c ld a, 12
ld [$fff7], a ld [hFieldMoveMonMenuTopMenuItemX], a
hlCoord 13, 12 hlCoord 13, 12
ld de, PokemonMenuEntries ld de, PokemonMenuEntries
jp PlaceString jp PlaceString
.asm_770f
.fieldMovesExist
push af push af
; Calculate the text box position and dimensions based on the leftmost X coord
; of the field move names before adjusting for the number of field moves.
hlCoord 0, 11 hlCoord 0, 11
ld a, [wcd42] ld a, [wFieldMovesLeftmostXCoord]
dec a dec a
ld e, a ld e, a
ld d, $0 ld d, 0
add hl, de add hl, de
ld b, $5 ld b, 5
ld a, $12 ld a, 18
sub e sub e
ld c, a ld c, a
pop af pop af
; For each field move, move the top of the text box up 2 rows while the leaving
; the bottom of the text box at the bottom of the screen.
ld de, -SCREEN_WIDTH * 2 ld de, -SCREEN_WIDTH * 2
.asm_7725 .textBoxHeightLoop
add hl, de add hl, de
inc b inc b
inc b inc b
dec a dec a
jr nz, .asm_7725 jr nz, .textBoxHeightLoop
; Make space for an extra blank row above the top field move.
ld de, -SCREEN_WIDTH ld de, -SCREEN_WIDTH
add hl, de add hl, de
inc b inc b
call TextBoxBorder call TextBoxBorder
call UpdateSprites call UpdateSprites
; Calculate the position of the first field move name to print.
hlCoord 0, 12 hlCoord 0, 12
ld a, [wcd42] ld a, [wFieldMovesLeftmostXCoord]
inc a inc a
ld e, a ld e, a
ld d, $0 ld d, 0
add hl, de add hl, de
ld de, -SCREEN_WIDTH * 2 ld de, -SCREEN_WIDTH * 2
ld a, [wTrainerScreenX] ld a, [wNumFieldMoves]
.asm_7747 .calcFirstFieldMoveYLoop
add hl, de add hl, de
dec a dec a
jr nz, .asm_7747 jr nz, .calcFirstFieldMoveYLoop
xor a xor a
ld [wTrainerScreenX], a ld [wNumFieldMoves], a
ld de, wWhichTrade ld de, wFieldMoves
.asm_7752 .printNamesLoop
push hl push hl
ld hl, FieldMoveNames ld hl, FieldMoveNames
ld a, [de] ld a, [de]
and a and a
jr z, .asm_7776 jr z, .donePrintingNames
inc de inc de
ld b, a ld b, a ; index of name
.asm_775c .skipNamesLoop ; skip past names before the name we want
dec b dec b
jr z, .asm_7766 jr z, .reachedName
.asm_775f .skipNameLoop ; skip past current name
ld a, [hli] ld a, [hli]
cp $50 cp "@"
jr nz, .asm_775f jr nz, .skipNameLoop
jr .asm_775c jr .skipNamesLoop
.asm_7766 .reachedName
ld b, h ld b, h
ld c, l ld c, l
pop hl pop hl
@ -1809,16 +1824,17 @@ DisplayFieldMoveMonMenu: ; 76e1 (1:36e1)
ld bc, SCREEN_WIDTH * 2 ld bc, SCREEN_WIDTH * 2
add hl, bc add hl, bc
pop de pop de
jr .asm_7752 jr .printNamesLoop
.asm_7776
.donePrintingNames
pop hl pop hl
ld a, [wcd42] ld a, [wFieldMovesLeftmostXCoord]
ld [$fff7], a ld [hFieldMoveMonMenuTopMenuItemX], a
hlCoord 0, 12 hlCoord 0, 12
ld a, [wcd42] ld a, [wFieldMovesLeftmostXCoord]
inc a inc a
ld e, a ld e, a
ld d, $0 ld d, 0
add hl, de add hl, de
ld de, PokemonMenuEntries ld de, PokemonMenuEntries
jp PlaceString jp PlaceString
@ -1842,59 +1858,58 @@ PokemonMenuEntries: ; 77c2 (1:77c2)
GetMonFieldMoves: ; 77d6 (1:77d6) GetMonFieldMoves: ; 77d6 (1:77d6)
ld a, [wWhichPokemon] ld a, [wWhichPokemon]
ld hl, wPartyMon1Moves ld hl, wPartyMon1Moves
ld bc, $2c ld bc, wPartyMon2 - wPartyMon1
call AddNTimes call AddNTimes
ld d, h ld d, h
ld e, l ld e, l
ld c, $5 ld c, NUM_MOVES + 1
ld hl, wWhichTrade ld hl, wFieldMoves
.asm_77e9 .loop
push hl push hl
.asm_77ea .nextMove
dec c dec c
jr z, .asm_7821 jr z, .done
ld a, [de] ; de is RAM address of move ld a, [de] ; move ID
and a and a
jr z, .asm_7821 jr z, .done
ld b, a ld b, a
inc de ; go to next move inc de
ld hl, FieldMoveDisplayData ld hl, FieldMoveDisplayData
.asm_77f6 .fieldMoveLoop
ld a, [hli] ld a, [hli]
cp $ff cp $ff
jr z, .asm_77ea jr z, .nextMove ; if the move is not a field move
cp b cp b
jr z, .asm_7802 jr z, .foundFieldMove
inc hl inc hl
inc hl inc hl
jr .asm_77f6 jr .fieldMoveLoop
.asm_7802 .foundFieldMove
ld a, b ld a, b
ld [wcd43], a ld [wLastFieldMoveID], a
ld a, [hli] ld a, [hli] ; field move name index
ld b, [hl] ld b, [hl] ; field move leftmost X coordinate
pop hl pop hl
ld [hli], a ld [hli], a ; store name index in wFieldMoves
ld a, [wTrainerScreenX] ld a, [wNumFieldMoves]
inc a inc a
ld [wTrainerScreenX], a ld [wNumFieldMoves], a
ld a, [wcd42] ld a, [wFieldMovesLeftmostXCoord]
cp b cp b
jr c, .asm_781b jr c, .skipUpdatingLeftmostXCoord
ld a, b ld a, b
ld [wcd42], a ld [wFieldMovesLeftmostXCoord], a
.asm_781b .skipUpdatingLeftmostXCoord
ld a, [wcd43] ld a, [wLastFieldMoveID]
ld b, a ld b, a
jr .asm_77e9 jr .loop
.asm_7821 .done
pop hl pop hl
ret ret
; Format: [Move id], [list priority], [leftmost tile] ; Format: [Move id], [name index], [leftmost tile]
; Move id = id of move ; Move id = id of move
; List priority = lower number means higher priority when field moves are displayed ; Name index = index of name in FieldMoveNames
; these priorities must be unique
; Leftmost tile = -1 + tile column in which the first letter of the move's name should be displayed ; Leftmost tile = -1 + tile column in which the first letter of the move's name should be displayed
; "SOFTBOILED" is $08 because it has 4 more letters than "SURF", for example, whose value is $0C ; "SOFTBOILED" is $08 because it has 4 more letters than "SURF", for example, whose value is $0C
FieldMoveDisplayData: ; 7823 (1:7823) FieldMoveDisplayData: ; 7823 (1:7823)

View file

@ -601,6 +601,10 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b
ds 1 ds 1
wFieldMoves:: ; cd3d
; 4 bytes
; the current mon's field moves
wBadgeNumberTile:: ; cd3d wBadgeNumberTile:: ; cd3d
; tile ID of the badge number being drawn ; tile ID of the badge number being drawn
@ -695,9 +699,11 @@ wTradedPlayerMonOT:: ; cd41
wHiddenObjectX:: ; cd41 wHiddenObjectX:: ; cd41
wSlotMachineWinningSymbol:: ; cd42 wSlotMachineWinningSymbol:: ; cd41
; the OAM tile number of the upper left corner of the winning symbol minus 2 ; the OAM tile number of the upper left corner of the winning symbol minus 2
wNumFieldMoves:: ; cd41
wSlotMachineWheel1BottomTile:: ; cd41 wSlotMachineWheel1BottomTile:: ; cd41
wTrainerScreenX:: ; cd41 wTrainerScreenX:: ; cd41
@ -706,11 +712,15 @@ wTrainerScreenX:: ; cd41
wSlotMachineWheel1MiddleTile:: ; cd42 wSlotMachineWheel1MiddleTile:: ; cd42
wFieldMovesLeftmostXCoord:: ; cd42
wcd42:: ds 1 ; used in pewter center script, printing field mon moves, slot machines and HoF PC wcd42:: ds 1 ; used in pewter center script, printing field mon moves, slot machines and HoF PC
wSlotMachineWheel1TopTile:: ; cd43 wLastFieldMoveID:: ; cd43
; unused
wcd43:: ds 1 ; slot machine stuff and GetMonFieldMoves wSlotMachineWheel1TopTile:: ; cd43
ds 1
wSlotMachineWheel2BottomTile:: ; cd44 wSlotMachineWheel2BottomTile:: ; cd44
ds 1 ds 1