summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--constants/wram_constants.asm2
-rw-r--r--engine/billspctop.asm4
-rwxr-xr-xengine/main_menu.asm6
-rwxr-xr-xengine/player_movement.asm735
-rw-r--r--home.asm6
-rwxr-xr-xitems/item_effects.asm2
-rw-r--r--main.asm11
-rw-r--r--wram.asm3
8 files changed, 753 insertions, 16 deletions
diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm
index 09d457f5..3561c9be 100644
--- a/constants/wram_constants.asm
+++ b/constants/wram_constants.asm
@@ -6,7 +6,7 @@ BOXMON EQU 2
TEMPMON EQU 3
WILDMON EQU 4
-; Options: ; cfcc
+; wOptions: ; cfcc
FAST_TEXT EQU 0
MED_TEXT EQU 1
SLOW_TEXT EQU 2
diff --git a/engine/billspctop.asm b/engine/billspctop.asm
index 4cb456ed..ccf50310 100644
--- a/engine/billspctop.asm
+++ b/engine/billspctop.asm
@@ -23,14 +23,14 @@ BillsPC_LogIn: ; e3f7 (3:63f7)
ld [hBGMapMode], a
call LoadStandardMenuDataHeader
call Functione566
- ld hl, Options
+ ld hl, wOptions
ld a, [hl]
push af
set 4, [hl]
ld hl, Text_BillsPCWhat
call PrintText
pop af
- ld [wd199], a
+ ld [wOptions], a
call Functionda5
ret
diff --git a/engine/main_menu.asm b/engine/main_menu.asm
index eb837145..5ecdf5b4 100755
--- a/engine/main_menu.asm
+++ b/engine/main_menu.asm
@@ -134,13 +134,13 @@ Function5b27: ; 5b27 (1:5b27)
xor a
ld [hBGMapMode], a
call Function5b45
- ld hl, wd199
+ ld hl, wOptions
ld a, [hl]
push af
set 4, [hl]
call Function5b5b
pop af
- ld [wd199], a
+ ld [wOptions], a
ld a, $1
ld [hBGMapMode], a
ret
@@ -267,7 +267,7 @@ Function5c3a: ; 5c3a (1:5c3a)
Function5c41: ; 5c41 (1:5c41)
ld hl, wOAMBuffer
- ld bc, Options - wOAMBuffer
+ ld bc, wOptions - wOAMBuffer
xor a
call ByteFill
diff --git a/engine/player_movement.asm b/engine/player_movement.asm
new file mode 100755
index 00000000..61b45a72
--- /dev/null
+++ b/engine/player_movement.asm
@@ -0,0 +1,735 @@
+DoPlayerMovement:: ; 10000 (4:4000)
+ call Function10017
+ ld a, movement_step_sleep
+ ld [wcf2d], a
+ xor a
+ ld [wcf2c], a
+ call Function1002d
+ ld c, a
+ ld a, [wcf2d]
+ ld [wce87], a
+ ret
+
+Function10017: ; 10017 (4:4017)
+ ld a, [hJoyDown]
+ ld [wcf29], a
+ CheckFlagHL ENGINE_DOWNHILL
+ ret z
+ ld c, a
+ and $f0
+ ret nz
+ ld a, c
+ or $80
+ ld [wcf29], a
+ ret
+
+Function1002d: ; 1002d (4:402d)
+ ld a, [wPlayerBikeSurfState]
+ cp PLAYER_NORMAL
+ jr z, .asm_10044
+ cp PLAYER_SURF
+ jr z, .asm_10060
+ cp PLAYER_SURF_PIKA
+ jr z, .asm_10060
+ cp PLAYER_BIKE
+ jr z, .asm_10044
+ cp PLAYER_SLIP
+ jr z, .asm_10074
+.asm_10044
+ call Function102cb
+ call Function102ec
+ call Function100b7
+ ret c
+ call Function10147
+ ret c
+ call Function1016b
+ ret c
+ call Function101f3
+ ret c
+ call Function10226
+ ret c
+ jr .asm_1009d
+
+.asm_10060
+ call Function102cb
+ call Function102ec
+ call Function100b7
+ ret c
+ call Function10147
+ ret c
+ call Function101c0
+ ret c
+ jr .asm_1009d
+
+.asm_10074
+ call Function102cb
+ call Function102ec
+ call Function100b7
+ ret c
+ call Function10147
+ ret c
+ call Function1016b
+ ret c
+ call Function101f3
+ ret c
+ call Function10226
+ ret c
+ ld a, [wcf2e]
+ cp $ff
+ jr z, .asm_10098
+ call Function103ee
+.asm_10098
+ call Function102b3
+ xor a
+ ret
+
+.asm_1009d
+ ld a, [wcf2e]
+ cp $ff
+ jr z, .asm_100b2
+ ld a, [wTempTrainerHeader]
+ and a
+ jr nz, .asm_100ad
+ call Function103ee
+.asm_100ad
+ call Function102bf
+ xor a
+ ret
+
+.asm_100b2
+ call Function102b3
+ xor a
+ ret
+
+Function100b7: ; 100b7 (4:40b7)
+ ld a, [wPlayerStandingTile]
+ ld c, a
+ call CheckWhirlpoolTile
+ jr c, .asm_100c4
+ ld a, $3
+ scf
+ ret
+
+.asm_100c4
+ and $f0
+ cp $30
+ jr z, .asm_100d8
+ cp $40
+ jr z, .asm_100ec
+ cp $50
+ jr z, .asm_10108
+ cp $70
+ jr z, .asm_10124
+ jr .asm_1013c
+
+.asm_100d8
+ ld a, c
+ and $3
+ ld c, a
+ ld b, $0
+ ld hl, .water_table
+ add hl, bc
+ ld a, [hl]
+ ld [wcf2e], a
+ jr .asm_1013e
+
+.water_table
+ db RIGHT
+ db LEFT
+ db UP
+ db DOWN
+
+.asm_100ec
+ ld a, c
+ and $7
+ ld c, a
+ ld b, $0
+ ld hl, .land1_table
+ add hl, bc
+ ld a, [hl]
+ cp $ff
+ jr z, .asm_1013c
+ ld [wcf2e], a
+ jr .asm_1013e
+
+.land1_table
+ db STANDING
+ db RIGHT
+ db LEFT
+ db UP
+ db DOWN
+ db STANDING
+ db STANDING
+ db STANDING
+
+.asm_10108
+ ld a, c
+ and $7
+ ld c, a
+ ld b, $0
+ ld hl, .land2_table
+ add hl, bc
+ ld a, [hl]
+ cp $ff
+ jr z, .asm_1013c
+ ld [wcf2e], a
+ jr .asm_1013e
+
+.land2_table
+ db RIGHT
+ db LEFT
+ db UP
+ db DOWN
+ db STANDING
+ db STANDING
+ db STANDING
+ db STANDING
+
+.asm_10124
+ ld a, c
+ cp $71
+ jr z, .asm_10135
+ cp $79
+ jr z, .asm_10135
+ cp $7a
+ jr z, .asm_10135
+ cp $7b
+ jr nz, .asm_1013c
+.asm_10135
+ ld a, $0
+ ld [wcf2e], a
+ jr .asm_1013e
+
+.asm_1013c
+ xor a
+ ret
+
+.asm_1013e
+ ld a, $1
+ call Function1025f
+ ld a, $5
+ scf
+ ret
+
+Function10147: ; 10147 (4:4147)
+ ld a, [wcf39]
+ cp $0
+ jr nz, .asm_10169
+ ld a, [wcf2e]
+ cp $ff
+ jr z, .asm_10169
+ ld e, a
+ ld a, [wPlayerDirection]
+ rrca
+ rrca
+ and $3
+ cp e
+ jr z, .asm_10169
+ ld a, $5
+ call Function1025f
+ ld a, $2
+ scf
+ ret
+
+.asm_10169
+ xor a
+ ret
+
+Function1016b: ; 1016b (4:416b)
+ ld a, [wPlayerBikeSurfState]
+ cp $4
+ jr z, Function101c0
+ cp $8
+ jr z, Function101c0
+ call Function1039e
+ jr c, .asm_101be
+ call Function10341
+ and a
+ jr z, .asm_101be
+ cp $2
+ jr z, .asm_101be
+ ld a, [wPlayerStandingTile]
+ call CheckIceTile
+ jr nc, .asm_101b5
+ call Function103ca
+ jr nz, .asm_101ae
+ ld hl, wBikeFlags
+ bit 2, [hl]
+ jr z, .asm_101a7
+ ld a, [wcf2e]
+ cp $0
+ jr z, .asm_101a7
+ ld a, $1
+ call Function1025f
+ scf
+ ret
+
+.asm_101a7
+ ld a, $2
+ call Function1025f
+ scf
+ ret
+
+.asm_101ae
+ ld a, $1
+ call Function1025f
+ scf
+ ret
+
+.asm_101b5
+ ld a, $4
+ call Function1025f
+ scf
+ ret
+
+ xor a
+ ret
+
+.asm_101be
+ xor a
+ ret
+
+Function101c0: ; 101c0 (4:41c0)
+ call Function103b4
+ ld [wcf2b], a
+ jr c, .asm_101f1
+ call Function10341
+ ld [wcf2a], a
+ and a
+ jr z, .asm_101f1
+ cp $2
+ jr z, .asm_101f1
+ ld a, [wcf2b]
+ and a
+ jr nz, .asm_101e2
+ ld a, $1
+ call Function1025f
+ scf
+ ret
+
+.asm_101e2
+ call Function103f9
+ call PlayMapMusic
+ ld a, $1
+ call Function1025f
+ ld a, $6
+ scf
+ ret
+
+.asm_101f1
+ xor a
+ ret
+
+Function101f3: ; 101f3 (4:41f3)
+ ld a, [wPlayerStandingTile]
+ ld e, a
+ and $f0
+ cp $a0
+ jr nz, .asm_1021c
+ ld a, e
+ and $7
+ ld e, a
+ ld d, $0
+ ld hl, .data_1021e
+ add hl, de
+ ld a, [wcf2f]
+ and [hl]
+ jr z, .asm_1021c
+ ld de, $16
+ call PlaySFX
+ ld a, $3
+ call Function1025f
+ ld a, $7
+ scf
+ ret
+
+.asm_1021c
+ xor a
+ ret
+
+.data_1021e
+ db FACE_RIGHT
+ db FACE_LEFT
+ db FACE_UP
+ db FACE_DOWN
+ db FACE_RIGHT | FACE_DOWN
+ db FACE_DOWN | FACE_LEFT
+ db FACE_UP | FACE_RIGHT
+ db FACE_UP | FACE_LEFT
+
+Function10226: ; 10226 (4:4226)
+ ld a, [wcf2e]
+ ld e, a
+ ld d, $0
+ ld hl, .edge_warps
+ add hl, de
+ ld a, [wPlayerStandingTile]
+ cp [hl]
+ jr nz, .asm_10259
+ ld a, $1
+ ld [wTempTrainerHeader], a
+ ld a, [wcf2e]
+ cp $ff
+ jr z, .asm_10259
+ ld e, a
+ ld a, [wPlayerDirection]
+ rrca
+ rrca
+ and $3
+ cp e
+ jr nz, .asm_10259
+ call Function22a5
+ jr nc, .asm_10259
+ call Function102b3
+ scf
+ ld a, $1
+ ret
+
+.asm_10259
+ xor a
+ ret
+
+.edge_warps
+ db $70, $78, $76, $7e
+
+Function1025f: ; 1025f (4:425f)
+ ld e, a
+ ld d, $0
+ ld hl, .Steps
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wcf2e]
+ ld e, a
+ cp $ff
+ jp z, Function102b3
+ add hl, de
+ ld a, [hl]
+ ld [wcf2d], a
+ ld hl, $42af
+ add hl, de
+ ld a, [hl]
+ ld [wcf39], a
+ ld a, $4
+ ret
+
+.Steps:
+ dw .SlowStep
+ dw .NormalStep
+ dw .FastStep
+ dw .JumpStep
+ dw .SlideStep
+ dw .TurningStep
+ dw .BackJumpStep
+ dw .FinishFacing
+
+.SlowStep:
+ slow_step DOWN
+ slow_step UP
+ slow_step LEFT
+ slow_step RIGHT
+.NormalStep:
+ step DOWN
+ step UP
+ step LEFT
+ step RIGHT
+.FastStep:
+ big_step DOWN
+ big_step UP
+ big_step LEFT
+ big_step RIGHT
+.JumpStep:
+ jump_step DOWN
+ jump_step UP
+ jump_step LEFT
+ jump_step RIGHT
+.SlideStep:
+ fast_slide_step DOWN
+ fast_slide_step UP
+ fast_slide_step LEFT
+ fast_slide_step RIGHT
+.BackJumpStep:
+ jump_step UP
+ jump_step DOWN
+ jump_step RIGHT
+ jump_step LEFT
+.TurningStep:
+ turn_step DOWN
+ turn_step UP
+ turn_step LEFT
+ turn_step RIGHT
+.FinishFacing:
+ db $80 + DOWN
+ db $80 + UP
+ db $80 + LEFT
+ db $80 + RIGHT
+
+Function102b3: ; 102b3 (4:42b3)
+ ld a, $0
+ ld [wcf39], a
+ ld a, $3e
+ ld [wcf2d], a
+ xor a
+ ret
+
+Function102bf: ; 102bf (4:42bf)
+ ld a, $0
+ ld [wTempTrainerHeaderEnd], a
+ ld a, $50
+ ld [wcf2d], a
+ xor a
+ ret
+
+Function102cb: ; 102cb (4:42cb)
+ call Function10404
+ ret nc
+ ld a, [wTempTrainerHeaderEnd]
+.asm_102d2
+ cp $0
+ ret z
+ and $3
+ ld e, a
+ ld d, $0
+ ld hl, .forced_dpad
+ add hl, de
+ ld a, [wcf29]
+ and $f
+ or [hl]
+ ld [wcf29], a
+ ret
+
+.forced_dpad
+ db D_DOWN, D_UP, D_LEFT, D_RIGHT
+
+Function102ec: ; 102ec (4:42ec)
+ ld hl, .table
+ ld de, .table2 - .table1
+ ld a, [wcf29]
+ bit 7, a
+ jr nz, .asm_10307
+ bit 6, a
+ jr nz, .asm_10308
+.asm_102fc
+ bit 5, a
+ jr nz, .asm_10309
+ bit 4, a
+ jr nz, .asm_1030a
+ jr .asm_1030b
+
+.asm_10307
+ add hl, de
+.asm_10308
+ add hl, de
+.asm_10309
+ add hl, de
+.asm_1030a
+ add hl, de
+.asm_1030b
+ ld a, [hli]
+ ld [wcf2e], a
+ ld a, [hli]
+ ld [wcf2f], a
+ ld a, [hli]
+ ld [wcf30], a
+ ld a, [hli]
+ ld [wcf31], a
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [hl]
+ ld [wWinTextPointer], a
+ ret
+
+.table
+; struct:
+; walk direction
+; facing
+; x movement
+; y movement
+; tile collision pointer
+.table1
+ db STANDING, FACE_CURRENT, 0, 0
+ dw wPlayerStandingTile
+.table2
+ db RIGHT, FACE_RIGHT, 1, 0
+ dw wTileRight
+ db LEFT, FACE_LEFT, -1, 0
+ dw wTileLeft
+ db UP, FACE_UP, 0, -1
+ dw wTileUp
+ db DOWN, FACE_DOWN, 0, 1
+ dw wTileDown
+
+Function10341: ; 10341 (4:4341)
+ ld a, 0
+ ld [hMapObjectIndexBuffer], a
+ ld a, [wPlayerStandingMapX]
+ ld d, a
+ ld a, [wcf30]
+ add d
+ ld d, a
+ ld a, [wPlayerStandingMapY]
+ ld e, a
+ ld a, [wcf31]
+ add e
+ ld e, a
+ ld bc, wPlayerSprite
+ callba Function7120
+ jr nc, .asm_10369
+ call Function1036f
+ jr c, .asm_1036c
+ xor a
+ ret
+
+.asm_10369
+ ld a, $1
+ ret
+
+.asm_1036c
+ ld a, $2
+ ret
+
+Function1036f: ; 1036f (4:436f)
+ ld hl, wBikeFlags
+ bit 0, [hl]
+ jr z, .asm_1039c
+ ld hl, $7
+ add hl, bc
+ ld a, [hl]
+ cp $ff
+ jr nz, .asm_1039c
+ ld hl, $6
+ add hl, bc
+ bit 6, [hl]
+ jr z, .asm_1039c
+ ld hl, $5
+ add hl, bc
+ set 2, [hl]
+ ld a, [wcf2e]
+ ld d, a
+ ld hl, $20
+ add hl, bc
+ ld a, [hl]
+ and $fc
+ or d
+ ld [hl], a
+ scf
+ ret
+
+.asm_1039c
+ xor a
+ ret
+
+Function1039e: ; 1039e (4:439e)
+ ld a, [wTilePermissions]
+ ld d, a
+ ld a, [wcf2f]
+ and d
+ jr nz, .asm_103b2
+ ld a, [wWinTextPointer]
+ call Function103d3
+ jr c, .asm_103b2
+ xor a
+ ret
+
+.asm_103b2
+ scf
+ ret
+
+Function103b4: ; 103b4 (4:43b4)
+ ld a, [wTilePermissions]
+ ld d, a
+ ld a, [wcf2f]
+ and d
+ jr nz, .asm_103c8
+ ld a, [wWinTextPointer]
+ call Function103da
+ jr c, .asm_103c8
+ and a
+ ret
+
+.asm_103c8
+ scf
+ ret
+
+Function103ca: ; 103ca (4:43ca)
+ ld a, [wPlayerBikeSurfState]
+ cp $1
+ ret z
+ cp $2
+ ret
+
+Function103d3: ; 103d3 (4:43d3)
+ call GetTileCollision
+ and a
+ ret z
+ scf
+ ret
+
+Function103da: ; 103da (4:43da)
+ call GetTileCollision
+ cp $1
+ jr z, .asm_103e6
+ and a
+ jr z, .asm_103e8
+ jr .asm_103ec
+
+.asm_103e6
+ xor a
+ ret
+
+.asm_103e8
+ ld a, $1
+ and a
+ ret
+
+.asm_103ec
+ scf
+ ret
+
+Function103ee: ; 103ee (4:43ee)
+ call CheckSFX
+ ret c
+ ld de, $24
+ call PlaySFX
+ ret
+
+Function103f9: ; 103f9 (4:43f9)
+ push bc
+ ld a, $0
+ ld [wPlayerBikeSurfState], a
+ call ReplacePlayerSprite
+ pop bc
+ ret
+
+Function10404: ; 10404 (4:4404)
+ ld a, [wTempTrainerHeaderEnd]
+ cp $0
+ jr z, .asm_10420
+ cp $f0
+ jr z, .asm_10420
+ ld a, [wPlayerStandingTile]
+ call CheckIceTile
+ jr nc, .asm_1041e
+ ld a, [wPlayerBikeSurfState]
+ cp $2
+ jr nz, .asm_10420
+.asm_1041e
+ scf
+ ret
+
+.asm_10420
+ and a
+ ret
+
+StopPlayerForEvent::
+ ld hl, wce87
+ ld a, $3e
+ cp [hl]
+ ret z
+ ld [hl], a
+ ld a, $0
+ ld [wcf39], a
+ ret
diff --git a/home.asm b/home.asm
index 2e28b95f..1af9effd 100644
--- a/home.asm
+++ b/home.asm
@@ -267,7 +267,7 @@ IsInArray::
INCLUDE "home/math.asm"
Function31e2:: ; 31e2 (0:31e2)
- ld a, [wd199]
+ ld a, [wOptions]
bit 4, a
ret nz
ld a, [wTextBoxFlags]
@@ -283,7 +283,7 @@ Function31e2:: ; 31e2 (0:31e2)
ld a, [wTextBoxFlags]
bit 0, a
jr z, .asm_3205
- ld a, [wd199]
+ ld a, [wOptions]
and $7
jr .asm_3207
@@ -928,7 +928,7 @@ NamesPointers:: ; 35ee (0:35ee)
dbw 0, wPartyMonOT
dbw 0, $de7d
dba TrainerClassNames
- dba Function10000
+ dba DoPlayerMovement
GetName:: ; 3606
ld a, [hROMBank]
diff --git a/items/item_effects.asm b/items/item_effects.asm
index a401fc04..b276c1e8 100755
--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -222,7 +222,7 @@ UltraBall: ; e926
ld a, [wd002]
cp PARK_BALL
call nz, ReturnToBattle_UseBall
- ld hl, Options
+ ld hl, wOptions
res NO_TEXT_SCROLL, [hl]
ld hl, Text_UsedItem ; $7884
call PrintText
diff --git a/main.asm b/main.asm
index 9a7d635c..d36da147 100644
--- a/main.asm
+++ b/main.asm
@@ -633,8 +633,11 @@ Text_KnowsMove:
db "@"
SECTION "bank4", ROMX, BANK[$4]
-Function10000::
- dr $10000, $117f1
+
+INCLUDE "engine/player_movement.asm"
+
+Function10430:
+ dr $10430, $117f1
InitializeStartDay_:
dr $117f1, $118f8
Function118f8:
@@ -749,7 +752,7 @@ LoadMapGroupRoof::
dr $1c000, $1ffbd
SECTION "bank8", ROMX, BANK[$8]
- dr $20000, $24000
+ dr $20000, $23e3d
SECTION "bank9", ROMX, BANK[$9]
StringBufferPointers::
@@ -791,7 +794,7 @@ Function27216:
GetTrainerDVs:
dr $27271, $27307
ReturnToBattle_UseBall_:
- dr $27307, $28000
+ dr $27307, $27bd3
SECTION "banka", ROMX, BANK[$a]
dr $28000, $28d88
diff --git a/wram.asm b/wram.asm
index ea4d1305..e2c2aee3 100644
--- a/wram.asm
+++ b/wram.asm
@@ -2713,8 +2713,7 @@ wd196:: ds 1 ; d196
wd197:: ds 1 ; d197
wd198:: ds 1 ; d198
-Options::
-wd199:: ds 1 ; d199
+wOptions:: ds 1 ; d199
wd19a:: ds 1 ; d19a
wd19b:: ds 1 ; d19b
wTextBoxFlags:: ds 1 ; d19c