pokecrystal/engine/npctrade.asm

587 lines
9.6 KiB
NASM
Raw Normal View History

2015-11-19 23:07:20 +00:00
NPCTrade:: ; fcba8
ld a, e
ld [wJumptableIndex], a
2015-11-23 05:21:21 +00:00
call Trade_GetDialog
2015-11-19 23:07:20 +00:00
ld b, CHECK_FLAG
call TradeFlagAction
ld a, TRADE_AFTER
jr nz, .done
ld a, TRADE_INTRO
call PrintTradeText
call YesNoBox
ld a, TRADE_CANCEL
jr c, .done
; Select givemon from party
ld b, PARTYMENUACTION_GIVE_MON
2017-12-24 17:47:30 +00:00
farcall SelectTradeOrDayCareMon
2015-11-19 23:07:20 +00:00
ld a, TRADE_CANCEL
jr c, .done
ld e, TRADE_GIVEMON
call GetTradeAttribute
ld a, [CurPartySpecies]
cp [hl]
ld a, TRADE_WRONG
jr nz, .done
call CheckTradeGender
ld a, TRADE_WRONG
jr c, .done
ld b, SET_FLAG
call TradeFlagAction
ld hl, ConnectLinkCableText
call PrintText
2015-11-23 05:21:21 +00:00
call DoNPCTrade
call .TradeAnimation
2015-11-19 23:07:20 +00:00
call GetTradeMonNames
ld hl, TradedForText
call PrintText
call RestartMapMusic
ld a, TRADE_COMPLETE
.done
call PrintTradeText
ret
; fcc07
2015-11-23 05:21:21 +00:00
.TradeAnimation: ; fcc07
2015-11-19 23:07:20 +00:00
call DisableSpriteUpdates
ld a, [wJumptableIndex]
push af
ld a, [wcf64]
push af
predef TradeAnimation
2015-11-19 23:07:20 +00:00
pop af
ld [wcf64], a
pop af
ld [wJumptableIndex], a
2015-12-19 01:07:09 +00:00
call ReturnToMapWithSpeechTextbox
2015-11-19 23:07:20 +00:00
ret
; fcc23
CheckTradeGender: ; fcc23
xor a
ld [MonType], a
ld e, TRADE_GENDER
call GetTradeAttribute
ld a, [hl]
2018-01-11 17:00:01 +00:00
and a ; TRADE_EITHER_GENDER
2015-12-14 01:33:56 +00:00
jr z, .matching
2018-01-11 17:00:01 +00:00
cp TRADE_MALE_ONLY
2015-12-14 01:33:56 +00:00
jr z, .check_male
2015-11-19 23:07:20 +00:00
farcall GetGender
2015-12-14 01:33:56 +00:00
jr nz, .not_matching
jr .matching
2015-11-19 23:07:20 +00:00
2015-12-14 01:33:56 +00:00
.check_male
farcall GetGender
2015-12-14 01:33:56 +00:00
jr z, .not_matching
2015-11-19 23:07:20 +00:00
2015-12-14 01:33:56 +00:00
.matching
2015-11-19 23:07:20 +00:00
and a
ret
2015-12-14 01:33:56 +00:00
.not_matching
2015-11-19 23:07:20 +00:00
scf
ret
; fcc4a
TradeFlagAction: ; fcc4a
2015-11-23 05:21:21 +00:00
ld hl, wTradeFlags
2015-11-19 23:07:20 +00:00
ld a, [wJumptableIndex]
ld c, a
predef SmallFarFlagAction
2015-11-19 23:07:20 +00:00
ld a, c
and a
ret
; fcc59
2015-11-23 05:21:21 +00:00
Trade_GetDialog: ; fcc59
2015-11-19 23:07:20 +00:00
ld e, TRADE_DIALOG
call GetTradeAttribute
ld a, [hl]
ld [wcf64], a
ret
; fcc63
2015-11-23 05:21:21 +00:00
DoNPCTrade: ; fcc63
2015-11-19 23:07:20 +00:00
ld e, TRADE_GIVEMON
call GetTradeAttribute
ld a, [hl]
2015-11-23 05:21:21 +00:00
ld [wPlayerTrademonSpecies], a
2015-11-19 23:07:20 +00:00
ld e, TRADE_GETMON
call GetTradeAttribute
ld a, [hl]
2015-11-23 05:21:21 +00:00
ld [wOTTrademonSpecies], a
2015-11-19 23:07:20 +00:00
2015-11-23 05:21:21 +00:00
ld a, [wPlayerTrademonSpecies]
ld de, wPlayerTrademonSpeciesName
call GetTradeMonName
call CopyTradeName
2015-11-19 23:07:20 +00:00
2015-11-23 05:21:21 +00:00
ld a, [wOTTrademonSpecies]
ld de, wOTTrademonSpeciesName
call GetTradeMonName
call CopyTradeName
2015-11-19 23:07:20 +00:00
ld hl, PartyMonOT
ld bc, NAME_LENGTH
2015-11-23 05:21:21 +00:00
call Trade_GetAttributeOfCurrentPartymon
ld de, wPlayerTrademonOTName
call CopyTradeName
2015-11-19 23:07:20 +00:00
ld hl, PlayerName
2015-11-23 05:21:21 +00:00
ld de, wPlayerTrademonSenderName
call CopyTradeName
2015-11-19 23:07:20 +00:00
ld hl, PartyMon1ID
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-23 05:21:21 +00:00
call Trade_GetAttributeOfCurrentPartymon
ld de, wPlayerTrademonID
call Trade_CopyTwoBytes
2015-11-19 23:07:20 +00:00
ld hl, PartyMon1DVs
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-23 05:21:21 +00:00
call Trade_GetAttributeOfCurrentPartymon
ld de, wPlayerTrademonDVs
call Trade_CopyTwoBytes
2015-11-19 23:07:20 +00:00
ld hl, PartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-23 05:21:21 +00:00
call Trade_GetAttributeOfCurrentPartymon
2015-11-19 23:07:20 +00:00
ld b, h
ld c, l
2017-12-24 17:47:30 +00:00
farcall GetCaughtGender
2015-11-19 23:07:20 +00:00
ld a, c
2015-11-23 05:21:21 +00:00
ld [wPlayerTrademonCaughtData], a
2015-11-19 23:07:20 +00:00
ld e, TRADE_DIALOG
call GetTradeAttribute
ld a, [hl]
2018-01-11 17:00:01 +00:00
cp TRADE_DIALOG_GIRL
ld a, CAUGHT_BY_GIRL
2015-11-23 05:21:21 +00:00
jr c, .okay
2018-01-11 17:00:01 +00:00
ld a, CAUGHT_BY_BOY
2015-11-23 05:21:21 +00:00
.okay
ld [wOTTrademonCaughtData], a
2015-11-19 23:07:20 +00:00
ld hl, PartyMon1Level
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-23 05:21:21 +00:00
call Trade_GetAttributeOfCurrentPartymon
2015-11-19 23:07:20 +00:00
ld a, [hl]
ld [CurPartyLevel], a
2015-11-23 05:21:21 +00:00
ld a, [wOTTrademonSpecies]
2015-11-19 23:07:20 +00:00
ld [CurPartySpecies], a
xor a
ld [MonType], a
ld [wPokemonWithdrawDepositParameter], a
2017-12-24 17:47:30 +00:00
callfar RemoveMonFromPartyOrBox
predef TryAddMonToParty
2015-11-19 23:07:20 +00:00
ld e, TRADE_DIALOG
call GetTradeAttribute
ld a, [hl]
cp TRADE_COMPLETE
2015-11-23 05:21:21 +00:00
ld b, RESET_FLAG
2015-12-14 01:33:56 +00:00
jr c, .incomplete
2015-11-23 05:21:21 +00:00
ld b, SET_FLAG
2015-12-14 01:33:56 +00:00
.incomplete
2017-12-24 17:47:30 +00:00
farcall SetGiftPartyMonCaughtData
2015-11-19 23:07:20 +00:00
ld e, TRADE_NICK
call GetTradeAttribute
2015-11-23 05:21:21 +00:00
ld de, wOTTrademonNickname
call CopyTradeName
2015-11-19 23:07:20 +00:00
ld hl, PartyMonNicknames
2018-01-20 17:25:55 +00:00
ld bc, MON_NAME_LENGTH
2015-11-23 05:21:21 +00:00
call Trade_GetAttributeOfLastPartymon
ld hl, wOTTrademonNickname
call CopyTradeName
2015-11-19 23:07:20 +00:00
ld e, TRADE_OT_NAME
call GetTradeAttribute
push hl
2015-11-23 05:21:21 +00:00
ld de, wOTTrademonOTName
call CopyTradeName
2015-11-19 23:07:20 +00:00
pop hl
2015-11-23 05:21:21 +00:00
ld de, wOTTrademonSenderName
call CopyTradeName
2015-11-19 23:07:20 +00:00
ld hl, PartyMonOT
ld bc, NAME_LENGTH
2015-11-23 05:21:21 +00:00
call Trade_GetAttributeOfLastPartymon
ld hl, wOTTrademonOTName
call CopyTradeName
2015-11-19 23:07:20 +00:00
ld e, TRADE_DVS
call GetTradeAttribute
2015-11-23 05:21:21 +00:00
ld de, wOTTrademonDVs
call Trade_CopyTwoBytes
2015-11-19 23:07:20 +00:00
ld hl, PartyMon1DVs
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-23 05:21:21 +00:00
call Trade_GetAttributeOfLastPartymon
ld hl, wOTTrademonDVs
call Trade_CopyTwoBytes
2015-11-19 23:07:20 +00:00
ld e, TRADE_OT_ID
call GetTradeAttribute
2015-11-23 05:21:21 +00:00
ld de, wOTTrademonID + 1
call Trade_CopyTwoBytesReverseEndian
2015-11-19 23:07:20 +00:00
ld hl, PartyMon1ID
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-23 05:21:21 +00:00
call Trade_GetAttributeOfLastPartymon
ld hl, wOTTrademonID
call Trade_CopyTwoBytes
2015-11-19 23:07:20 +00:00
ld e, TRADE_ITEM
call GetTradeAttribute
push hl
ld hl, PartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
2015-11-23 05:21:21 +00:00
call Trade_GetAttributeOfLastPartymon
2015-11-19 23:07:20 +00:00
pop hl
ld a, [hl]
ld [de], a
push af
push bc
push de
push hl
ld a, [CurPartyMon]
push af
ld a, [PartyCount]
dec a
ld [CurPartyMon], a
2017-12-24 17:47:30 +00:00
farcall ComputeNPCTrademonStats
2015-11-19 23:07:20 +00:00
pop af
ld [CurPartyMon], a
pop hl
pop de
pop bc
pop af
ret
; fcdc2
GetTradeAttribute: ; 0xfcdc2
ld d, 0
push de
ld a, [wJumptableIndex]
and $f
swap a
ld e, a
ld d, 0
ld hl, NPCTrades
add hl, de
add hl, de
2015-11-19 23:07:20 +00:00
pop de
add hl, de
ret
; 0xfcdd7
2015-11-23 05:21:21 +00:00
Trade_GetAttributeOfCurrentPartymon: ; fcdd7
2015-11-19 23:07:20 +00:00
ld a, [CurPartyMon]
call AddNTimes
ret
; fcdde
2015-11-23 05:21:21 +00:00
Trade_GetAttributeOfLastPartymon: ; fcdde
2015-11-19 23:07:20 +00:00
ld a, [PartyCount]
dec a
call AddNTimes
ld e, l
ld d, h
ret
; fcde8
2015-11-23 05:21:21 +00:00
GetTradeMonName: ; fcde8
2015-11-19 23:07:20 +00:00
push de
ld [wd265], a
call GetBasePokemonName
ld hl, StringBuffer1
pop de
ret
; fcdf4
2015-11-23 05:21:21 +00:00
CopyTradeName: ; fcdf4
2015-11-19 23:07:20 +00:00
ld bc, NAME_LENGTH
call CopyBytes
ret
; fcdfb
2018-01-02 15:04:21 +00:00
Unreferenced_Functionfcdfb: ; fcdfb
2015-11-19 23:07:20 +00:00
ld bc, 4
call CopyBytes
2015-11-23 05:21:21 +00:00
ld a, "@"
2015-11-19 23:07:20 +00:00
ld [de], a
ret
; fce05
2018-01-02 15:04:21 +00:00
Unreferenced_Functionfce05: ; fce05
2015-11-19 23:07:20 +00:00
ld bc, 3
call CopyBytes
2015-11-23 05:21:21 +00:00
ld a, "@"
2015-11-19 23:07:20 +00:00
ld [de], a
ret
; fce0f
2015-11-23 05:21:21 +00:00
Trade_CopyTwoBytes: ; fce0f
2015-11-19 23:07:20 +00:00
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
ret
; fce15
2015-11-23 05:21:21 +00:00
Trade_CopyTwoBytesReverseEndian: ; fce15
2015-11-19 23:07:20 +00:00
ld a, [hli]
ld [de], a
dec de
ld a, [hl]
ld [de], a
ret
; fce1b
GetTradeMonNames: ; fce1b
ld e, TRADE_GETMON
call GetTradeAttribute
ld a, [hl]
2015-11-23 05:21:21 +00:00
call GetTradeMonName
2015-11-19 23:07:20 +00:00
ld de, StringBuffer2
2015-11-23 05:21:21 +00:00
call CopyTradeName
2015-11-19 23:07:20 +00:00
ld e, TRADE_GIVEMON
call GetTradeAttribute
ld a, [hl]
2015-11-23 05:21:21 +00:00
call GetTradeMonName
2015-11-19 23:07:20 +00:00
2015-12-19 01:07:09 +00:00
ld de, wMonOrItemNameBuffer
2015-11-23 05:21:21 +00:00
call CopyTradeName
2015-11-19 23:07:20 +00:00
ld hl, StringBuffer1
.loop
ld a, [hli]
cp "@"
jr nz, .loop
dec hl
push hl
ld e, TRADE_GENDER
call GetTradeAttribute
ld a, [hl]
pop hl
and a
ret z
2018-01-11 17:00:01 +00:00
cp TRADE_MALE_ONLY
2015-11-19 23:07:20 +00:00
ld a, "♂"
jr z, .done
ld a, "♀"
.done
ld [hli], a
ld [hl], "@"
ret
; fce58
INCLUDE "data/npc_trades.asm"
2015-11-19 23:07:20 +00:00
PrintTradeText: ; fcf38
push af
call GetTradeMonNames
pop af
ld bc, 2 * 4
ld hl, TradeTexts
call AddNTimes
ld a, [wcf64]
ld c, a
add hl, bc
add hl, bc
2015-11-19 23:07:20 +00:00
ld a, [hli]
ld h, [hl]
ld l, a
call PrintText
ret
; fcf53
TradeTexts: ; fcf53
2018-01-11 17:00:01 +00:00
; entries correspond to TRADE_* × TRADE_DIALOG_* constants
; TRADE_INTRO
2015-11-19 23:07:20 +00:00
dw TradeIntroText1
dw TradeIntroText2
dw TradeIntroText3
dw TradeIntroText4
2018-01-11 17:00:01 +00:00
; TRADE_CANCEL
2015-11-19 23:07:20 +00:00
dw TradeCancelText1
dw TradeCancelText2
dw TradeCancelText3
dw TradeCancelText4
2018-01-11 17:00:01 +00:00
; TRADE_WRONG
2015-11-19 23:07:20 +00:00
dw TradeWrongText1
dw TradeWrongText2
dw TradeWrongText3
dw TradeWrongText4
2018-01-11 17:00:01 +00:00
; TRADE_COMPLETE
2015-11-19 23:07:20 +00:00
dw TradeCompleteText1
dw TradeCompleteText2
dw TradeCompleteText3
dw TradeCompleteText4
2018-01-11 17:00:01 +00:00
; TRADE_AFTER
2015-11-19 23:07:20 +00:00
dw TradeAfterText1
dw TradeAfterText2
dw TradeAfterText3
dw TradeAfterText4
; fcf7b
ConnectLinkCableText: ; 0xfcf7b
; OK, connect the Game Link Cable.
text_jump UnknownText_0x1bd407
db "@"
; 0xfcf80
TradedForText: ; 0xfcf80
; traded givemon for getmon
text_jump UnknownText_0x1bd429
start_asm
ld de, MUSIC_NONE
call PlayMusic
call DelayFrame
ld hl, .done
ret
.done
2015-11-24 02:19:53 +00:00
; sound_dex_fanfare_80_109
2015-11-19 23:07:20 +00:00
; interpret_data
text_jump UnknownText_0x1bd445
db "@"
; 0xfcf97
TradeIntroText1: ; 0xfcf97
; I collect #MON. Do you have @ ? Want to trade it for my @ ?
text_jump UnknownText_0x1bd449
db "@"
; 0xfcf9c
TradeCancelText1: ; 0xfcf9c
; You don't want to trade? Aww…
text_jump UnknownText_0x1bd48c
db "@"
; 0xfcfa1
TradeWrongText1: ; 0xfcfa1
; Huh? That's not @ . What a letdown…
text_jump UnknownText_0x1bd4aa
db "@"
; 0xfcfa6
TradeCompleteText1: ; 0xfcfa6
; Yay! I got myself @ ! Thanks!
text_jump UnknownText_0x1bd4d2
db "@"
; 0xfcfab
TradeAfterText1: ; 0xfcfab
; Hi, how's my old @ doing?
text_jump UnknownText_0x1bd4f4
db "@"
; 0xfcfb0
TradeIntroText2:
TradeIntroText3: ; 0xfcfb0
; Hi, I'm looking for this #MON. If you have @ , would you trade it for my @ ?
text_jump UnknownText_0x1bd512
db "@"
; 0xfcfb5
TradeCancelText2:
TradeCancelText3: ; 0xfcfb5
; You don't have one either? Gee, that's really disappointing…
text_jump UnknownText_0x1bd565
db "@"
; 0xfcfba
TradeWrongText2:
TradeWrongText3: ; 0xfcfba
; You don't have @ ? That's too bad, then.
text_jump UnknownText_0x1bd5a1
db "@"
; 0xfcfbf
TradeCompleteText2: ; 0xfcfbf
; Great! Thank you! I finally got @ .
text_jump UnknownText_0x1bd5cc
db "@"
; 0xfcfc4
TradeAfterText2: ; 0xfcfc4
; Hi! The @ you traded me is doing great!
text_jump UnknownText_0x1bd5f4
db "@"
; 0xfcfc9
TradeIntroText4: ; 0xfcfc9
; 's cute, but I don't have it. Do you have @ ? Want to trade it for my @ ?
text_jump UnknownText_0x1bd621
db "@"
; 0xfcfce
TradeCancelText4: ; 0xfcfce
; You don't want to trade? Oh, darn…
text_jump UnknownText_0x1bd673
db "@"
; 0xfcfd3
TradeWrongText4: ; 0xfcfd3
; That's not @ . Please trade with me if you get one.
text_jump UnknownText_0x1bd696
db "@"
; 0xfcfd8
TradeCompleteText4: ; 0xfcfd8
; Wow! Thank you! I always wanted @ !
text_jump UnknownText_0x1bd6cd
db "@"
; 0xfcfdd
TradeAfterText4: ; 0xfcfdd
; How is that @ I traded you doing? Your @ 's so cute!
text_jump UnknownText_0x1bd6f5
db "@"
; 0xfcfe2
TradeCompleteText3: ; 0xfcfe2
; Uh? What happened?
text_jump UnknownText_0x1bd731
db "@"
; 0xfcfe7
TradeAfterText3: ; 0xfcfe7
; Trading is so odd… I still have a lot to learn about it.
text_jump UnknownText_0x1bd745
db "@"
; 0xfcfec