forked from gameboyadvancesp/understanding-pokemon-red
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload_mon_data.asm
68 lines (59 loc) · 1.57 KB
/
load_mon_data.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
; **LoadMonData_**
; [wMonDataLocation]から[wWhichPokemon]で指定したポケモンのデータをロードする
; - - -
;
; INPUT:
; wWhichPokemon: wMonDataLocation内のポケモンのインデックス
; wMonDataLocation:
; 0: パーティのポケモン
; 1: 敵のポケモン
; 2: ボックスのポケモン
; 3: 育て屋のポケモン
;
; OUTPUT:
; [wcf91] = ポケモンのID
; [wLoadedMon] = Pokemon Data
; [wMonHeader] = Pokemon Header
LoadMonData_:
; 育て屋の場合は wDayCareMonSpecies にポケモンのIDが入っている
ld a, [wDayCareMonSpecies]
ld [wcf91], a
ld a, [wMonDataLocation]
cp DAYCARE_DATA
jr z, .GetMonHeader
; それらの場合は専用の関数を使って取得する
ld a, [wWhichPokemon]
ld e, a
callab GetMonSpecies
; INPUT: [wcf91] = ポケモンのID
.GetMonHeader
ld a, [wcf91]
ld [wd0b5], a ; input for GetMonHeader
call GetMonHeader
ld hl, wPartyMons
ld bc, wPartyMon2 - wPartyMon1
ld a, [wMonDataLocation]
; 自分のパーティのポケモン
cp ENEMY_PARTY_DATA
jr c, .getMonEntry
; 相手のパーティのポケモン
ld hl, wEnemyMons
jr z, .getMonEntry
cp 2
ld hl, wBoxMons
ld bc, wBoxMon2 - wBoxMon1
jr z, .getMonEntry
ld hl, wDayCareMon
jr .copyMonData
; INPUT:
; - a = どのポケモンがセレクトされているか
; - hl = リストの先頭
; - bc = リストの各エントリのサイズ
.getMonEntry
ld a, [wWhichPokemon]
call AddNTimes ; hl = リストの対象のエントリ
;
.copyMonData
ld de, wLoadedMon
ld bc, wPartyMon2 - wPartyMon1
jp CopyData