forked from gameboyadvancesp/understanding-pokemon-red
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit_player_data.asm
73 lines (63 loc) · 1.81 KB
/
init_player_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
69
70
71
72
73
; **InitPlayerData**
; ゲームを『はじめから』始めたときにプレイヤーデータを初期化する
; - - -
; - IDをランダムに決定
; - 手持ち、PCBoxのポケモンとバッグ、PCBoxのアイテムをまっさらに
; - 所持金を3000に
; - バッジ個数を0に初期化
; - ゲームコインを0に初期化
; - ゲーム進行フラグをすべて0に初期化
; - MissableObjectsフラグを初期化
InitPlayerData:
; InitPlayerDataと同じ
InitPlayerData2:
; IDをランダムに決定する
call Random
ld a, [hRandomSub]
ld [wPlayerID], a
call Random
ld a, [hRandomAdd]
ld [wPlayerID + 1], a
ld a, $ff
ld [wUnusedD71B], a
; 手持ち、PCBoxのポケモンとバッグ、PCBoxのアイテムをまっさらに
ld hl, wPartyCount
call InitializeEmptyList
ld hl, wNumInBox
call InitializeEmptyList
ld hl, wNumBagItems
call InitializeEmptyList
ld hl, wNumBoxItems
call InitializeEmptyList
; 所持金を3000に設定
START_MONEY EQU $3000
ld hl, wPlayerMoney + 1
ld a, START_MONEY / $100
ld [hld], a ; xx30xx
xor a
ld [hli], a ; xxxx00
inc hl
ld [hl], a ; 00xxxx => 003000
; TODO: ???
ld [wMonDataLocation], a
; バッジ個数を0に初期化
ld hl, wObtainedBadges
ld [hli], a ; flag_array = 0
ld [hl], a
; ゲームコインを0に初期化
ld hl, wPlayerCoins
ld [hli], a
ld [hl], a
; ゲーム進行フラグをすべて0に初期化
ld hl, wGameProgressFlags
ld bc, wGameProgressFlagsEnd - wGameProgressFlags
call FillMemory
; MissableObjectsフラグを初期化
jp InitializeMissableObjectsFlags
; listは 最初のバイトが要素数、最後のバイトが終端記号なので、最初と最後のバイトを0にすることでlistを初期化する
InitializeEmptyList:
xor a ; count
ld [hli], a
dec a ; terminator
ld [hl], a
ret