Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
akatsuki105 committed May 11, 2020
1 parent 0a16365 commit 36c6d7a
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
- [メニュー](./docs/menu.md)
- [movement byte](./docs/movement_byte.md)
- [OAM](./docs/oam.md)
- [pewter guys](./docs/pewter_guys.md)
- [picファイル](./docs/pic_format.md)
- [ポケモン図鑑](./docs/pokedex.md)
- [predef](./docs/predef.md)
- [rgbgfx](./docs/rgbgfx.md)
- [simulated joypad](./docs/simulated_joypad.md)
- [スプライトデータ](./docs/sprite_data.md)
- [スプライト](./docs/sprite.md)
- [用語](./docs/term.md)
Expand Down
4 changes: 4 additions & 0 deletions docs/joypad.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@
## キー入力の加工

キー入力の結果が必要な時に呼び出され、上記の3種類の変数に加工されたキー入力の状態が格納される

## 関連

- [simulated joypad](./simulated_joypad.md)
18 changes: 18 additions & 0 deletions docs/pewter_guys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# pewter guy

ニビシティの特殊なNPCのこと 2種類いる

`engine/overworld/pewter_guys.md`で処理が定義されている

## museum guy

TODO

## gym guy

ニビシティのジムバッジを持っていないときにニビシティのジムまでプレイヤーを連行するNPC

## 関連

- [simulated joypad](./simulated_joypad.md)

21 changes: 21 additions & 0 deletions docs/simulated_joypad.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# simulated joypad

ポケモン赤にシミュレートされたキー入力のこと
つまりゲームによって勝手にキー入力をされている状態

pewter guyなどNPCの強制連行イベントなどでこの状態になる

## description

- wSimulatedJoypadStatesEnd
- wSimulatedJoypadStatesIndex

の2種類のアドレスの値が`simulated joypad`と関連している

プレイヤーの`simulated joypad`によるキー入力は`wSimulatedJoypadStatesEnd + [wSimulatedJoypadStatesIndex]`の値となる

simulated joypadの1入力のたびに`wSimulatedJoypadStatesIndex`の値がデクリメントされ、`wSimulatedJoypadStatesEnd + [wSimulatedJoypadStatesIndex]`の値が`wSimulatedJoypadStatesEnd`と等しいとき、つまり`[wSimulatedJoypadStatesIndex]`が0のときに`simulated joypad`状態は終了する

## 関連

- [pewter guy](./pewter_guys.md)
28 changes: 28 additions & 0 deletions engine/overworld/pewter_guys.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,71 @@
; ニビシティのジムに連行するNPCについて
PewterGuys:
ld hl, wSimulatedJoypadStatesEnd

; [wSimulatedJoypadStatesIndex]--
ld a, [wSimulatedJoypadStatesIndex]
dec a ; this decrement causes it to overwrite the last byte before $FF in the list
ld [wSimulatedJoypadStatesIndex], a
; de = wSimulatedJoypadStatesEnd + [wSimulatedJoypadStatesIndex]
ld d, 0
ld e, a
add hl, de
ld d, h
ld e, l

; hl = PewterMuseumGuyCoords([wWhichPewterGuy] = 0) or PewterGymGuyCoords([wWhichPewterGuy] = 1)
ld hl, PointerTable_37ce6
ld a, [wWhichPewterGuy]
add a
ld b, 0
ld c, a
add hl, bc

; 最初のエントリのcoord (findMatchingCoordsLoopのinit処理)
ld a, [hli]
ld h, [hl]
ld l, a
; bc = プレイヤーのcoord
ld a, [wYCoord]
ld b, a
ld a, [wXCoord]
ld c, a

; イベントcoordのリストからプレイヤーのcoordと一致するものを探索
.findMatchingCoordsLoop
; 検討中のイベントcoordと一致しないなら次のエントリ
ld a, [hli]
cp b
jr nz, .nextEntry1
ld a, [hli]
cp c
jr nz, .nextEntry2

; プレイヤーがイベントマスにいる
ld a, [hli]
ld h, [hl]
ld l, a

; イベントcoordのmovement data(e.g. .down, .one)
.copyMovementDataLoop
; a = 現在のループでのmovement data
ld a, [hli]
; movement dataが終了(ループが終了)
cp $ff
ret z

; wSimulatedJoypadStatesEnd + [wSimulatedJoypadStatesIndex] = movement data
ld [de], a
inc de

; [wSimulatedJoypadStatesIndex]++
ld a, [wSimulatedJoypadStatesIndex]
inc a
ld [wSimulatedJoypadStatesIndex], a
; 次のループ
jr .copyMovementDataLoop
.nextEntry1
inc hl
Expand All @@ -57,6 +82,8 @@ PointerTable_37ce6:
; these are the four coordinates of the spaces below, above, to the left and
; to the right of the museum guy, and pointers to different movements for
; the player to make to get positioned before the main movement.
;
; 『ニビ科学博物館』のスプライトの上下左右のcoordsのテーブル
PewterMuseumGuyCoords:
db 18, 27
dw .down
Expand All @@ -80,6 +107,7 @@ PewterMuseumGuyCoords:
; different movements for the player to make to get positioned before the
; main movement
; $00 is a pause
; gym guyによる連行イベントのトリガーとなる5個のcoordsと ???
PewterGymGuyCoords:
db 16, 34
dw .one
Expand Down
9 changes: 5 additions & 4 deletions wram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ wFilteredBagItemsCount::
ds 1

; cd38
; 次に勝手に入力されるキー入力は、wSimulatedJoypadStatesEndに存在しこの値から1を引いたもの
; 次に勝手に入力されるキー入力は、wSimulatedJoypadStatesEndにこの値から1を引いた値を足したもの
; 0 ならキー入力はシミュレートされていない(ポケモン赤によって勝手にキー入力されている状態ではない)
wSimulatedJoypadStatesIndex::
ds 1
Expand Down Expand Up @@ -2266,9 +2266,10 @@ wMenuExitMethod:: ; d12e
wDungeonWarpDataEntrySize:: ; d12f
; the size is always 6, so they didn't need a variable in RAM for this

wWhichPewterGuy:: ; d12f
; 0 = museum guy
; 1 = gym guy
; d12f
; 0 = museum guy
; 1 = gym guy
wWhichPewterGuy::

wWhichPrizeWindow:: ; d12f
; there are 3 windows, from 0 to 2
Expand Down

0 comments on commit 36c6d7a

Please sign in to comment.