More link trade shenanigans

This commit is contained in:
PikalaxALT
2015-12-21 14:10:16 -05:00
parent 047effba94
commit 630d789c70
21 changed files with 746 additions and 745 deletions

View File

@@ -286,7 +286,7 @@ HatchEggs: ; 16f70 (5:6f70)
ld [hl], a
pop hl
push hl
ld bc, MON_EXP + 2
ld bc, MON_STAT_EXP - 1
add hl, bc
ld b, $0
predef CalcPkmnStats

View File

@@ -164,7 +164,7 @@ ForgetMove: ; 65d3
xor a
ld [w2DMenuFlags2], a
ld a, $20
ld [w2DMenuFlags3], a
ld [w2DMenuCursorOffsets], a
call StaticMenuJoypad
push af
call Call_LoadTempTileMapToTileMap

File diff suppressed because it is too large Load Diff

359
engine/link_trade.asm Executable file
View File

@@ -0,0 +1,359 @@
__LoadTradeScreenBorder: ; 16d421
ld de, GFX_16cfc1
ld hl, VTiles2
lb bc, BANK(GFX_16cfc1), 70
call Get2bpp
ret
; 16d42e
Function16d42e: ; 16d42e
ld hl, Tilemap_16d465
decoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyBytes
ret
; 16d43b
Function16d43b: ; 16d43b
call LoadStandardMenuDataHeader
call ClearBGPalettes
call ClearTileMap
call ClearSprites
callba __LoadTradeScreenBorder ; useless to farcall
callba Function16d42e ; useless to farcall
ld b, SCGB_08
call GetSGBLayout
call SetPalettes
call WaitBGMap
call JoyWaitAorB
call Call_ExitMenu
ret
; 16d465
Tilemap_16d465:
INCBIN "gfx/unknown/16d465.tilemap"
Tilemap_16d5cd:
INCBIN "gfx/unknown/16d5cd.tilemap"
Tilemap_16d5f5:
INCBIN "gfx/unknown/16d5f5.tilemap"
_LinkTextbox: ; 16d61d
ld h, d
ld l, e
push bc
push hl
call .draw_border
pop hl
pop bc
ld de, AttrMap - TileMap
add hl, de
inc b
inc b
inc c
inc c
ld a, $7
.loop
push bc
push hl
.loop2
ld [hli], a
dec c
jr nz, .loop2
pop hl
ld de, SCREEN_WIDTH
add hl, de
pop bc
dec b
jr nz, .loop
ret
; 16d640
.draw_border: ; 16d640
push hl
ld a, $30
ld [hli], a
inc a
call .fill_row
inc a
ld [hl], a
pop hl
ld de, SCREEN_WIDTH
add hl, de
.loop3
push hl
ld a, $33
ld [hli], a
ld a, " "
call .fill_row
ld [hl], $34
pop hl
ld de, SCREEN_WIDTH
add hl, de
dec b
jr nz, .loop3
ld a, $35
ld [hli], a
ld a, $36
call .fill_row
ld [hl], $37
ret
; 16d66d
.fill_row: ; 16d66d
ld d, c
.loop4
ld [hli], a
dec d
jr nz, .loop4
ret
; 16d673
InitTradeSpeciesList: ; 16d673
call _LoadTradeScreenBorder
call Function16d6ae
callba InitMG_Mobile_LinkTradePalMap
callba PlaceTradePartnerNamesAndParty
hlcoord 10, 17
ld de, .CANCEL
call PlaceString
ret
; 16d68f
.CANCEL: ; 16d68f
db "CANCEL@"
; 16d696
_LoadTradeScreenBorder: ; 16d696
call __LoadTradeScreenBorder
ret
; 16d69a
Function16d69a: ; 16d69a
ld de, GFX_16cfc1 + $300
ld hl, VTiles2 tile $76
lb bc, BANK(GFX_16cfc1), 8
call Get2bpp
ret
; 16d6a7
Function16d6a7: ; 16d6a7
callba Function49811
ret
; 16d6ae
Function16d6ae: ; 16d6ae
call Function16d42e
ld hl, Tilemap_16d5cd
decoord 0, 0
ld bc, 2 * SCREEN_WIDTH
call CopyBytes
ld hl, Tilemap_16d5f5
decoord 0, 16
ld bc, 2 * SCREEN_WIDTH
call CopyBytes
ret
; 16d6ca
LinkTextbox: ; 16d6ca
call _LinkTextbox
ret
; 16d6ce
Function16d6ce: ; 16d6ce
call LoadStandardMenuDataHeader
call Function16d6e1
callba Function87d
call Call_ExitMenu
call WaitBGMap2
ret
; 16d6e1
Function16d6e1: ; 16d6e1
hlcoord 4, 10
ld b, 1
ld c, 10
predef Predef_LinkTextbox
hlcoord 5, 11
ld de, .Waiting
call PlaceString
call WaitBGMap
call WaitBGMap2
ld c, 50
jp DelayFrames
; 16d701
.Waiting: ; 16d701
db "WAITING..!@"
; 16d70c
LinkTradeMenu: ; 16d70c
call .MenuAction
call .GetJoypad
ret
; 16d713
.GetJoypad: ; 16d713
push bc
push af
ld a, [hJoyLast]
and D_PAD
ld b, a
ld a, [hJoyPressed]
and BUTTONS
or b
ld b, a
pop af
ld a, b
pop bc
ld d, a
ret
; 16d725
.MenuAction: ; 16d725
ld hl, w2DMenuFlags2
res 7, [hl]
ld a, [hBGMapMode]
push af
call .loop
pop af
ld [hBGMapMode], a
ret
.loop
call .UpdateCursor
call .UpdateBGMapAndOAM
call .loop2
jr nc, .done
callba _2DMenuInterpretJoypad
jr c, .done
ld a, [w2DMenuFlags1]
bit 7, a
jr nz, .done
call .GetJoypad
ld b, a
ld a, [wMenuJoypadFilter]
and b
jr z, .loop
.done
ret
; 16d759
.UpdateBGMapAndOAM: ; 16d759
ld a, [hOAMUpdate]
push af
ld a, $1
ld [hOAMUpdate], a
call WaitBGMap
pop af
ld [hOAMUpdate], a
xor a
ld [hBGMapMode], a
ret
.loop2
call RTC
call .TryAnims
ret c
ld a, [w2DMenuFlags1]
bit 7, a
jr z, .loop2
and a
ret
; 16d77a
.UpdateCursor: ; 16d77a
ld hl, wCursorCurrentTile
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [hl]
cp $1f
jr nz, .not_currently_selected
ld a, [wCursorOffCharacter]
ld [hl], a
push hl
push bc
ld bc, PKMN_NAME_LENGTH
add hl, bc
ld [hl], a
pop bc
pop hl
.not_currently_selected
ld a, [w2DMenuCursorInitY]
ld b, a
ld a, [w2DMenuCursorInitX]
ld c, a
call Coord2Tile
ld a, [w2DMenuCursorOffsets]
swap a
and $f
ld c, a
ld a, [wMenuCursorY]
ld b, a
xor a
dec b
jr z, .skip
.loop3
add c
dec b
jr nz, .loop3
.skip
ld c, SCREEN_WIDTH
call AddNTimes
ld a, [w2DMenuCursorOffsets]
and $f
ld c, a
ld a, [wMenuCursorX]
ld b, a
xor a
dec b
jr z, .skip2
.loop4
add c
dec b
jr nz, .loop4
.skip2
ld c, a
add hl, bc
ld a, [hl]
cp $1f
jr z, .cursor_already_there
ld [wCursorOffCharacter], a
ld [hl], $1f
push hl
push bc
ld bc, PKMN_NAME_LENGTH
add hl, bc
ld [hl], $1f
pop bc
pop hl
.cursor_already_there
ld a, l
ld [wCursorCurrentTile], a
ld a, h
ld [wCursorCurrentTile + 1], a
ret
; 16d7e7
.TryAnims: ; 16d7e7
ld a, [w2DMenuFlags1]
bit 6, a
jr z, .skip_anims
callba PlaySpriteAnimationsAndDelayFrame
.skip_anims
call JoyTextDelay
call .GetJoypad
and a
ret z
scf
ret
; 16d7fe

View File

@@ -239,8 +239,8 @@ Init2DMenuCursorPosition: ; 2411a (9:411a)
.InitFlags_b: ; 2418a
ld a, [wMenuData2Spacing]
or %00100000
ld [w2DMenuFlags3], a
or $20
ld [w2DMenuCursorOffsets], a
ret
; 24193
@@ -536,7 +536,7 @@ Place2DMenuCursor: ; 24329
ld a, [w2DMenuCursorInitX]
ld c, a
call Coord2Tile
ld a, [w2DMenuFlags3]
ld a, [w2DMenuCursorOffsets]
swap a
and $f
ld c, a
@@ -553,7 +553,7 @@ Place2DMenuCursor: ; 24329
.got_row
ld c, SCREEN_WIDTH
call AddNTimes
ld a, [w2DMenuFlags3]
ld a, [w2DMenuCursorOffsets]
and $f
ld c, a
ld a, [wMenuCursorX]
@@ -809,8 +809,8 @@ _InitVerticalMenuCursor:: ; 2446d
; w2DMenuFlags2
xor a
ld [hli], a
; w2DMenuFlags3
ld a, %00100000
; w2DMenuCursorOffsets
ln a, 2, 0
ld [hli], a
; wMenuJoypadFilter
ld a, A_BUTTON

View File

@@ -309,7 +309,7 @@ ScrollingMenu_InitFlags: ; 24764
xor a
ld [w2DMenuFlags2], a
ld a, $20
ld [w2DMenuFlags3], a
ld [w2DMenuCursorOffsets], a
ld a, A_BUTTON | B_BUTTON | D_UP | D_DOWN
bit 7, c
jr z, .disallow_select

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
; These functions seem to be related to backwards compatibility
Functionfb57e: ; fb57e
ValidateOTTrademon: ; fb57e
ld a, [wd003]
ld hl, OTPartyMon1Species
call GetPartyLocation
@@ -14,21 +14,21 @@ Functionfb57e: ; fb57e
ld a, [hl]
pop hl
cp EGG
jr z, .asm_fb59c
jr z, .matching_or_egg
cp [hl]
jr nz, .asm_fb5db
jr nz, .abnormal
.asm_fb59c
.matching_or_egg
ld b, h
ld c, l
ld hl, MON_LEVEL
add hl, bc
ld a, [hl]
cp 101
jr nc, .asm_fb5db
cp MAX_LEVEL + 1
jr nc, .abnormal
ld a, [wLinkMode]
cp LINK_TIMECAPSULE
jr nz, .asm_fb5d9
jr nz, .normal
ld hl, OTPartySpecies
ld a, [wd003]
ld c, a
@@ -39,29 +39,29 @@ Functionfb57e: ; fb57e
; Magnemite and Magneton's types changed
; from Electric to Electric/Steel.
cp MAGNEMITE
jr z, .asm_fb5d9
jr z, .normal
cp MAGNETON
jr z, .asm_fb5d9
jr z, .normal
ld [CurSpecies], a
call GetBaseData
ld hl, wcbea
ld hl, wLinkOTPartyMonTypes
rept 2
add hl, bc
endr
ld a, [BaseType1]
cp [hl]
jr nz, .asm_fb5db
jr nz, .abnormal
inc hl
ld a, [BaseType2]
cp [hl]
jr nz, .asm_fb5db
jr nz, .abnormal
.asm_fb5d9
.normal
and a
ret
.asm_fb5db
.abnormal
scf
ret
; fb5dd
@@ -72,10 +72,10 @@ Functionfb5dd: ; fb5dd
ld a, [PartyCount]
ld b, a
ld c, $0
.asm_fb5e7
.loop
ld a, c
cp d
jr z, .asm_fb5f8
jr z, .next
push bc
ld a, c
ld hl, PartyMon1HP
@@ -83,48 +83,47 @@ Functionfb5dd: ; fb5dd
pop bc
ld a, [hli]
or [hl]
jr nz, .asm_fb60b
jr nz, .done
.asm_fb5f8
.next
inc c
dec b
jr nz, .asm_fb5e7
jr nz, .loop
ld a, [wd003]
ld hl, OTPartyMon1HP
call GetPartyLocation
ld a, [hli]
or [hl]
jr nz, .asm_fb60b
jr nz, .done
scf
ret
.asm_fb60b
.done
and a
ret
; fb60d
Functionfb60d: ; fb60d
PlaceTradePartnerNamesAndParty: ; fb60d
hlcoord 4, 0
ld de, PlayerName
call PlaceString
ld a, $14
ld [bc], a
hlcoord 4, 8
ld de, wd26b
ld de, OTPlayerName
call PlaceString
ld a, $14
ld [bc], a
hlcoord 7, 1
ld de, PartySpecies
call Functionfb634
call .PlaceSpeciesNames
hlcoord 7, 9
ld de, OTPartySpecies
Functionfb634: ; fb634
.PlaceSpeciesNames: ; fb634
ld c, $0
.asm_fb636
.loop
ld a, [de]
cp $ff
cp -1
ret z
ld [wd265], a
push bc
@@ -143,7 +142,7 @@ Functionfb634: ; fb634
add hl, bc
pop bc
inc c
jr .asm_fb636
jr .loop
; fb656
KantoMonSpecials: ; fb656

View File

@@ -215,7 +215,7 @@ TMHM_PocketLoop: ; 2c8d3 (b:48d3)
xor a
ld [w2DMenuFlags2], a
ld a, $20
ld [w2DMenuFlags3], a
ld [w2DMenuCursorOffsets], a
ld a, A_BUTTON | B_BUTTON | D_UP | D_DOWN | D_LEFT | D_RIGHT
ld [wMenuJoypadFilter], a
ld a, [wTMHMPocketCursor]