diff options
author | pikalaxalt <PikalaxALT@gmail.com> | 2016-06-18 16:00:37 -0400 |
---|---|---|
committer | pikalaxalt <PikalaxALT@gmail.com> | 2016-06-18 16:00:37 -0400 |
commit | ce39e05e3234f43a6a7ecdde4b48e9e5d2eaac98 (patch) | |
tree | 3a774def35dced8a73e17a4a9058e0ff32830f6c | |
parent | 42e609cb48486c055cc3657e5f3306946367f7c1 (diff) |
Map object step types
-rwxr-xr-x | engine/map_objects.asm | 655 | ||||
-rwxr-xr-x | engine/movement_pattern.asm | 651 | ||||
-rwxr-xr-x | engine/step_types.asm | 754 |
3 files changed, 1407 insertions, 653 deletions
diff --git a/engine/map_objects.asm b/engine/map_objects.asm index 05138129..73992fe7 100755 --- a/engine/map_objects.asm +++ b/engine/map_objects.asm @@ -398,660 +398,9 @@ Function4732: pop bc ret -RestoreDefaultMovement: - ld hl, $1 - add hl, bc - ld a, [hl] - cp $ff - jr z, .asm_4756 - push bc - call GetMapObject - ld hl, $4 - add hl, bc - ld a, [hl] - pop bc - ret - -.asm_4756 - ld a, $6 - ret - -ClearObjectMovementByteIndex: - ld hl, $1b - add hl, bc - ld [hl], $0 - ret - -IncrementObjectMovementByteIndex: - ld hl, $1b - add hl, bc - inc [hl] - ret - -DecrementObjectMovementByteIndex: - ld hl, $1b - add hl, bc - dec [hl] - ret - -MovementAnonymousJumptable: - ld hl, $1b - add hl, bc - ld a, [hl] - pop hl - rst JumpTable - ret - -ClearObjectStructField28: - ld hl, $1c - add hl, bc - ld [hl], $0 - ret - -IncrementObjectStructField28: - ld hl, $1c - add hl, bc - inc [hl] - ret - -Object28AnonymousJumptable: - ld hl, $1c - add hl, bc - ld a, [hl] - pop hl - rst JumpTable - ret - -GetValueObjectStructField28: - ld hl, $1c - add hl, bc - ld a, [hl] - ret - -SetValueObjectStructField28: - ld hl, $1c - add hl, bc - ld [hl], a - ret - -ObjectMovementReset: ; 4795 (1:4795) - ld hl, $10 - add hl, bc - ld d, [hl] - ld hl, $11 - add hl, bc - ld e, [hl] - push bc - call GetCoordTile - pop bc - ld hl, $e - add hl, bc - ld [hl], a - call CopyNextCoordsTileToStandingCoordsTile - call EndSpriteMovement - ld hl, $9 - add hl, bc - ld [hl], $1 - ret - -MapObjectMovementPattern: ; 47b6 (1:47b6) - call ClearObjectStructField28 - call GetSpriteMovementFunction - ld a, [hl] - ld hl, .Pointers - rst JumpTable - ret - -.Pointers: - dw Function47fa - dw Function47fb - dw Function4805 - dw Function4811 - dw Function481b - dw Function482a - dw Function4842 - dw Function4855 - dw Function485b - dw Function4861 - dw Function4867 - dw Function486a - dw Function486d - dw Function4870 - dw Function4876 - dw Function4879 - dw Function487f - dw Function4885 - dw Function48d8 - dw Function49be - dw Function49fa - dw Function4931 - dw Function4947 - dw Function4a95 - dw Function4966 - dw Function495d - dw Function4a1f - dw Function4a62 - -Function47fa: - ret - -Function47fb: ; 47fb (1:47fb) - call Random - ld a, [hRandom] - and $1 - jp Function4ac9 - -Function4805: ; 4805 (1:4805) - call Random - ld a, [hRandom] - and $1 - or $2 - jp Function4ac9 - -Function4811: ; 4811 (1:4811) - call Random - ld a, [hRandom] - and $3 - jp Function4ac9 - -Function481b: ; 481b (1:481b) - call Random - ld a, [hRandom] - and $c - ld hl, $8 - add hl, bc - ld [hl], a - jp Function4af6 - -Function482a: ; 482a (1:482a) - ld hl, $8 - add hl, bc - ld a, [hl] - and $c - ld d, a - call Random - ld a, [hRandom] - and $c - cp d - jr nz, .asm_483e - xor $c -.asm_483e - ld [hl], a - jp Function4aff - -Function4842: ; 4842 (1:4842) - call Function4603 - call EndSpriteMovement - ld hl, $b - add hl, bc - ld [hl], $1 - ld hl, $9 - add hl, bc - ld [hl], $5 - ret - -Function4855: ; 4855 (1:4855) - ld hl, $4fa8 - jp Function4fe9 - -Function485b: ; 485b (1:485b) - ld hl, $4fbd - jp Function4fe9 - -Function4861: ; 4861 (1:4861) - ld hl, $4fce - jp Function4fe9 - -Function4867: ; 4867 (1:4867) - jp Function4fdf - -Function486a: ; 486a (1:486a) - jp Function4fdf - -Function486d: ; 486d (1:486d) - jp Function4fdf - -Function4870: ; 4870 (1:4870) - ld hl, $4fa8 - jp Function4fe9 - -Function4876: ; 4876 (1:4876) - jp Function4fdf - -Function4879: ; 4879 (1:4879) - ld hl, $5485 - jp Function4fe9 - -Function487f: ; 487f (1:487f) - ld hl, $4fb6 - jp Function4fe9 - -Function4885: ; 4885 (1:4885) - call MovementAnonymousJumptable - dw .asm_488c - dw .asm_48d1 - -.asm_488c - ld hl, $e - add hl, bc - ld a, [hl] - call CheckPitTile - jr z, .asm_48ce - ld hl, $5 - add hl, bc - bit 2, [hl] - res 2, [hl] - jr z, .asm_48c7 - ld hl, $20 - add hl, bc - ld a, [hl] - and $3 - or $0 - call InitStep - call CheckNPCMovementPermissions - jr c, .asm_48c4 - ld de, $1b - call PlaySFX - call Function54d7 - call UpdateGrassPriority - ld hl, $9 - add hl, bc - ld [hl], $f - ret - -.asm_48c4 - call Function4603 -.asm_48c7 - ld hl, $7 - add hl, bc - ld [hl], $ff - ret - -.asm_48ce - call IncrementObjectMovementByteIndex -.asm_48d1 - ld hl, $7 - add hl, bc - ld [hl], $ff - ret - -Function48d8: ; 48d8 (1:48d8) - ld hl, $10 - add hl, bc - ld d, [hl] - ld hl, $11 - add hl, bc - ld e, [hl] - ld hl, $20 - add hl, bc - ld a, [hl] - push bc - call GetObjectStruct - ld hl, $7 - add hl, bc - ld a, [hl] - cp $ff - jr z, .asm_4923 - ld hl, $12 - add hl, bc - ld a, [hl] - cp d - jr z, .asm_4906 - jr c, .asm_4902 - ld a, $3 - jr .asm_4916 - -.asm_4902 - ld a, $2 - jr .asm_4916 - -.asm_4906 - ld hl, $13 - add hl, bc - ld a, [hl] - cp e - jr z, .asm_4923 - jr c, .asm_4914 - ld a, $0 - jr .asm_4916 - -.asm_4914 - ld a, $1 -.asm_4916 - ld d, a - ld hl, $7 - add hl, bc - ld a, [hl] - and $c - or d - pop bc - jp Function53b1 - -.asm_4923 - pop bc - ld hl, $7 - add hl, bc - ld [hl], $ff - ld hl, $b - add hl, bc - ld [hl], $1 - ret - -Function4931: ; 4931 (1:4931) - call EndSpriteMovement - ld hl, $7 - add hl, bc - ld [hl], $ff - ld hl, $b - add hl, bc - ld [hl], $9 - ld hl, $9 - add hl, bc - ld [hl], $4 - ret - -Function4947: ; 4947 (1:4947) - call EndSpriteMovement - ld hl, $7 - add hl, bc - ld [hl], $ff - ld hl, $b - add hl, bc - ld [hl], $a - ld hl, $9 - add hl, bc - ld [hl], $4 - ret - -Function495d: ; 495d (1:495d) - call MovementAnonymousJumptable - dw Function496f - dw Function4975 - dw Function4991 - -Function4966: ; 4966 (1:4966) - call MovementAnonymousJumptable - dw Function496f - dw Function4975 - dw Function499d - -Function496f: - call EndSpriteMovement - call IncrementObjectMovementByteIndex -Function4975: - ld hl, $b - add hl, bc - ld [hl], $1 - ld hl, $20 - add hl, bc - ld a, [hl] - ld a, $10 - ld hl, $a - add hl, bc - ld [hl], a - ld hl, $9 - add hl, bc - ld [hl], $3 - call IncrementObjectMovementByteIndex - ret - -Function4991: - ld de, .data - call Function49a9 - jr Function495d - -.data - db OW_RIGHT, OW_LEFT, OW_DOWN, OW_UP - -Function499d: - ld de, .data - call Function49a9 - jr Function4966 - -.data - db OW_LEFT, OW_RIGHT, OW_UP, OW_DOWN - -Function49a9: ; 49a9 (1:49a9) - ld hl, $8 - add hl, bc - ld a, [hl] - and $c - rrca - rrca - push hl - ld l, a - ld h, $0 - add hl, de - ld a, [hl] - pop hl - ld [hl], a - call DecrementObjectMovementByteIndex - ret - -Function49be: ; 49be (1:49be) - call Function4a81 - ld hl, $b - add hl, bc - ld [hl], $7 - ld hl, $a - add hl, de - ld a, [hl] - inc a - add a - add $0 - ld hl, $a - add hl, bc - ld [hl], a - ld hl, $7 - add hl, de - ld a, [hl] - and $3 - ld d, $e - cp $0 - jr z, .asm_49e8 - cp $1 - jr z, .asm_49e8 - ld d, $c -.asm_49e8 - ld hl, $1a - add hl, bc - ld [hl], d - ld hl, $19 - add hl, bc - ld [hl], $0 - ld hl, $9 - add hl, bc - ld [hl], $13 - ret - -Function49fa: ; 49fa (1:49fa) - call EndSpriteMovement - call Function4a81 - ld hl, $b - add hl, bc - ld [hl], $8 - ld hl, $a - add hl, bc - ld [hl], $0 - ld hl, $1a - add hl, bc - ld [hl], $f0 - ld hl, $19 - add hl, bc - ld [hl], $0 - ld hl, $9 - add hl, bc - ld [hl], $13 - ret - -Function4a1f: ; 4a1f (1:4a1f) - call EndSpriteMovement - call Function4a81 - ld hl, $b - add hl, bc - ld [hl], $e - ld hl, $a - add hl, de - ld a, [hl] - inc a - add a - ld hl, $a - add hl, bc - ld [hl], a - ld hl, $7 - add hl, de - ld a, [hl] - and $3 - ld e, a - ld d, $0 - ld hl, .data - add hl, de - add hl, de - ld d, [hl] - inc hl - ld e, [hl] - ld hl, $19 - add hl, bc - ld [hl], d - ld hl, $1a - add hl, bc - ld [hl], e - ld hl, $9 - add hl, bc - ld [hl], $13 - ret - -.data - ; x, y - db 0, -4 - db 0, 8 - db 6, 2 - db -6, 2 - -Function4a62: ; 4a62 (1:4a62) - call EndSpriteMovement - call Function4a81 - ld hl, $b - add hl, bc - ld [hl], $f - ld hl, $a - add hl, de - ld a, [hl] - add $ff - ld hl, $a - add hl, bc - ld [hl], a - ld hl, $9 - add hl, bc - ld [hl], $13 - ret - -Function4a81: ; 4a81 (1:4a81) - ld hl, $20 - add hl, bc - ld a, [hl] - push bc - call GetObjectStruct - ld d, b - ld e, c - pop bc - ld hl, $1d - add hl, bc - ld [hl], e - inc hl - ld [hl], d - ret - -Function4a95: ; 4a95 (1:4a95) - call EndSpriteMovement - ld hl, $b - add hl, bc - ld [hl], $0 - ld hl, $20 - add hl, bc - ld a, [hl] - call Function4ab7 - ld hl, $a - add hl, bc - ld [hl], e - ld hl, $1e - add hl, bc - ld [hl], a - ld hl, $9 - add hl, bc - ld [hl], $15 - ret - -Function4ab7: ; 4ab7 (1:4ab7) - ld d, a - and $3f - ld e, a - ld a, d - rlca - rlca - and $3 - ld d, a - inc d - ld a, $1 -.asm_4ac4 - dec d - ret z - add a - jr .asm_4ac4 - -Function4ac9: ; 4ac9 (1:4ac9) - call InitStep - call CheckNPCMovementPermissions - jr c, .asm_4af0 - call UpdateGrassPriority - ld hl, $b - add hl, bc - ld [hl], $2 - ld hl, wCenteredObject - ld a, [hConnectionStripLength] - cp [hl] - jr z, .asm_4ae9 - ld hl, $9 - add hl, bc - ld [hl], $7 - ret - -.asm_4ae9 - ld hl, $9 - add hl, bc - ld [hl], $6 - ret - -.asm_4af0 - call EndSpriteMovement - call Function4603 -Function4af6: ; 4af6 (1:4af6) - call Random - ld a, [hRandom] - and $7f - jr asm_4b06 - -Function4aff: ; 4aff (1:4aff) - call Random - ld a, [hRandomAdd] - and $1f -asm_4b06 - ld hl, $a - add hl, bc - ld [hl], a - ld hl, $7 - add hl, bc - ld [hl], $ff - ld hl, $b - add hl, bc - ld [hl], $1 - ld hl, $9 - add hl, bc - ld [hl], $3 - ret +INCLUDE "engine/movement_pattern.asm" +INCLUDE "engine/step_types.asm" -StepTypesJumptable: ; 4b1e - dr $4b1e, $4fdf Function4fdf: dr $4fdf, $4fe9 Function4fe9: diff --git a/engine/movement_pattern.asm b/engine/movement_pattern.asm new file mode 100755 index 00000000..0b7617ca --- /dev/null +++ b/engine/movement_pattern.asm @@ -0,0 +1,651 @@ +RestoreDefaultMovement: + ld hl, $1 + add hl, bc + ld a, [hl] + cp $ff + jr z, .asm_4756 + push bc + call GetMapObject + ld hl, $4 + add hl, bc + ld a, [hl] + pop bc + ret + +.asm_4756 + ld a, $6 + ret + +ClearObjectMovementByteIndex: + ld hl, $1b + add hl, bc + ld [hl], $0 + ret + +IncrementObjectMovementByteIndex: + ld hl, $1b + add hl, bc + inc [hl] + ret + +DecrementObjectMovementByteIndex: + ld hl, $1b + add hl, bc + dec [hl] + ret + +MovementAnonymousJumptable: + ld hl, $1b + add hl, bc + ld a, [hl] + pop hl + rst JumpTable + ret + +ClearObjectStructField28: + ld hl, $1c + add hl, bc + ld [hl], $0 + ret + +IncrementObjectStructField28: + ld hl, $1c + add hl, bc + inc [hl] + ret + +Object28AnonymousJumptable: + ld hl, $1c + add hl, bc + ld a, [hl] + pop hl + rst JumpTable + ret + +GetValueObjectStructField28: + ld hl, $1c + add hl, bc + ld a, [hl] + ret + +SetValueObjectStructField28: + ld hl, $1c + add hl, bc + ld [hl], a + ret + +ObjectMovementReset: ; 4795 (1:4795) + ld hl, $10 + add hl, bc + ld d, [hl] + ld hl, $11 + add hl, bc + ld e, [hl] + push bc + call GetCoordTile + pop bc + ld hl, $e + add hl, bc + ld [hl], a + call CopyNextCoordsTileToStandingCoordsTile + call EndSpriteMovement + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +MapObjectMovementPattern: ; 47b6 (1:47b6) + call ClearObjectStructField28 + call GetSpriteMovementFunction + ld a, [hl] + ld hl, .Pointers + rst JumpTable + ret + +.Pointers: + dw Function47fa + dw Function47fb + dw Function4805 + dw Function4811 + dw Function481b + dw Function482a + dw Function4842 + dw Function4855 + dw Function485b + dw Function4861 + dw Function4867 + dw Function486a + dw Function486d + dw Function4870 + dw Function4876 + dw Function4879 + dw Function487f + dw Function4885 + dw Function48d8 + dw Function49be + dw Function49fa + dw Function4931 + dw Function4947 + dw Function4a95 + dw Function4966 + dw Function495d + dw Function4a1f + dw Function4a62 + +Function47fa: + ret + +Function47fb: ; 47fb (1:47fb) + call Random + ld a, [hRandom] + and $1 + jp Function4ac9 + +Function4805: ; 4805 (1:4805) + call Random + ld a, [hRandom] + and $1 + or $2 + jp Function4ac9 + +Function4811: ; 4811 (1:4811) + call Random + ld a, [hRandom] + and $3 + jp Function4ac9 + +Function481b: ; 481b (1:481b) + call Random + ld a, [hRandom] + and $c + ld hl, $8 + add hl, bc + ld [hl], a + jp Function4af6 + +Function482a: ; 482a (1:482a) + ld hl, $8 + add hl, bc + ld a, [hl] + and $c + ld d, a + call Random + ld a, [hRandom] + and $c + cp d + jr nz, .asm_483e + xor $c +.asm_483e + ld [hl], a + jp Function4aff + +Function4842: ; 4842 (1:4842) + call Function4603 + call EndSpriteMovement + ld hl, $b + add hl, bc + ld [hl], $1 + ld hl, $9 + add hl, bc + ld [hl], $5 + ret + +Function4855: ; 4855 (1:4855) + ld hl, $4fa8 + jp Function4fe9 + +Function485b: ; 485b (1:485b) + ld hl, $4fbd + jp Function4fe9 + +Function4861: ; 4861 (1:4861) + ld hl, $4fce + jp Function4fe9 + +Function4867: ; 4867 (1:4867) + jp Function4fdf + +Function486a: ; 486a (1:486a) + jp Function4fdf + +Function486d: ; 486d (1:486d) + jp Function4fdf + +Function4870: ; 4870 (1:4870) + ld hl, $4fa8 + jp Function4fe9 + +Function4876: ; 4876 (1:4876) + jp Function4fdf + +Function4879: ; 4879 (1:4879) + ld hl, $5485 + jp Function4fe9 + +Function487f: ; 487f (1:487f) + ld hl, $4fb6 + jp Function4fe9 + +Function4885: ; 4885 (1:4885) + call MovementAnonymousJumptable + dw .asm_488c + dw .asm_48d1 + +.asm_488c + ld hl, $e + add hl, bc + ld a, [hl] + call CheckPitTile + jr z, .asm_48ce + ld hl, $5 + add hl, bc + bit 2, [hl] + res 2, [hl] + jr z, .asm_48c7 + ld hl, $20 + add hl, bc + ld a, [hl] + and $3 + or $0 + call InitStep + call CheckNPCMovementPermissions + jr c, .asm_48c4 + ld de, $1b + call PlaySFX + call Function54d7 + call UpdateGrassPriority + ld hl, $9 + add hl, bc + ld [hl], $f + ret + +.asm_48c4 + call Function4603 +.asm_48c7 + ld hl, $7 + add hl, bc + ld [hl], $ff + ret + +.asm_48ce + call IncrementObjectMovementByteIndex +.asm_48d1 + ld hl, $7 + add hl, bc + ld [hl], $ff + ret + +Function48d8: ; 48d8 (1:48d8) + ld hl, $10 + add hl, bc + ld d, [hl] + ld hl, $11 + add hl, bc + ld e, [hl] + ld hl, $20 + add hl, bc + ld a, [hl] + push bc + call GetObjectStruct + ld hl, $7 + add hl, bc + ld a, [hl] + cp $ff + jr z, .asm_4923 + ld hl, $12 + add hl, bc + ld a, [hl] + cp d + jr z, .asm_4906 + jr c, .asm_4902 + ld a, $3 + jr .asm_4916 + +.asm_4902 + ld a, $2 + jr .asm_4916 + +.asm_4906 + ld hl, $13 + add hl, bc + ld a, [hl] + cp e + jr z, .asm_4923 + jr c, .asm_4914 + ld a, $0 + jr .asm_4916 + +.asm_4914 + ld a, $1 +.asm_4916 + ld d, a + ld hl, $7 + add hl, bc + ld a, [hl] + and $c + or d + pop bc + jp Function53b1 + +.asm_4923 + pop bc + ld hl, $7 + add hl, bc + ld [hl], $ff + ld hl, $b + add hl, bc + ld [hl], $1 + ret + +Function4931: ; 4931 (1:4931) + call EndSpriteMovement + ld hl, $7 + add hl, bc + ld [hl], $ff + ld hl, $b + add hl, bc + ld [hl], $9 + ld hl, $9 + add hl, bc + ld [hl], $4 + ret + +Function4947: ; 4947 (1:4947) + call EndSpriteMovement + ld hl, $7 + add hl, bc + ld [hl], $ff + ld hl, $b + add hl, bc + ld [hl], $a + ld hl, $9 + add hl, bc + ld [hl], $4 + ret + +Function495d: ; 495d (1:495d) + call MovementAnonymousJumptable + dw Function496f + dw Function4975 + dw Function4991 + +Function4966: ; 4966 (1:4966) + call MovementAnonymousJumptable + dw Function496f + dw Function4975 + dw Function499d + +Function496f: + call EndSpriteMovement + call IncrementObjectMovementByteIndex +Function4975: + ld hl, $b + add hl, bc + ld [hl], $1 + ld hl, $20 + add hl, bc + ld a, [hl] + ld a, $10 + ld hl, $a + add hl, bc + ld [hl], a + ld hl, $9 + add hl, bc + ld [hl], $3 + call IncrementObjectMovementByteIndex + ret + +Function4991: + ld de, .data + call Function49a9 + jr Function495d + +.data + db OW_RIGHT, OW_LEFT, OW_DOWN, OW_UP + +Function499d: + ld de, .data + call Function49a9 + jr Function4966 + +.data + db OW_LEFT, OW_RIGHT, OW_UP, OW_DOWN + +Function49a9: ; 49a9 (1:49a9) + ld hl, $8 + add hl, bc + ld a, [hl] + and $c + rrca + rrca + push hl + ld l, a + ld h, $0 + add hl, de + ld a, [hl] + pop hl + ld [hl], a + call DecrementObjectMovementByteIndex + ret + +Function49be: ; 49be (1:49be) + call Function4a81 + ld hl, $b + add hl, bc + ld [hl], $7 + ld hl, $a + add hl, de + ld a, [hl] + inc a + add a + add $0 + ld hl, $a + add hl, bc + ld [hl], a + ld hl, $7 + add hl, de + ld a, [hl] + and $3 + ld d, $e + cp $0 + jr z, .asm_49e8 + cp $1 + jr z, .asm_49e8 + ld d, $c +.asm_49e8 + ld hl, $1a + add hl, bc + ld [hl], d + ld hl, $19 + add hl, bc + ld [hl], $0 + ld hl, $9 + add hl, bc + ld [hl], $13 + ret + +Function49fa: ; 49fa (1:49fa) + call EndSpriteMovement + call Function4a81 + ld hl, $b + add hl, bc + ld [hl], $8 + ld hl, $a + add hl, bc + ld [hl], $0 + ld hl, $1a + add hl, bc + ld [hl], $f0 + ld hl, $19 + add hl, bc + ld [hl], $0 + ld hl, $9 + add hl, bc + ld [hl], $13 + ret + +Function4a1f: ; 4a1f (1:4a1f) + call EndSpriteMovement + call Function4a81 + ld hl, $b + add hl, bc + ld [hl], $e + ld hl, $a + add hl, de + ld a, [hl] + inc a + add a + ld hl, $a + add hl, bc + ld [hl], a + ld hl, $7 + add hl, de + ld a, [hl] + and $3 + ld e, a + ld d, $0 + ld hl, .data + add hl, de + add hl, de + ld d, [hl] + inc hl + ld e, [hl] + ld hl, $19 + add hl, bc + ld [hl], d + ld hl, $1a + add hl, bc + ld [hl], e + ld hl, $9 + add hl, bc + ld [hl], $13 + ret + +.data + ; x, y + db 0, -4 + db 0, 8 + db 6, 2 + db -6, 2 + +Function4a62: ; 4a62 (1:4a62) + call EndSpriteMovement + call Function4a81 + ld hl, $b + add hl, bc + ld [hl], $f + ld hl, $a + add hl, de + ld a, [hl] + add $ff + ld hl, $a + add hl, bc + ld [hl], a + ld hl, $9 + add hl, bc + ld [hl], $13 + ret + +Function4a81: ; 4a81 (1:4a81) + ld hl, $20 + add hl, bc + ld a, [hl] + push bc + call GetObjectStruct + ld d, b + ld e, c + pop bc + ld hl, $1d + add hl, bc + ld [hl], e + inc hl + ld [hl], d + ret + +Function4a95: ; 4a95 (1:4a95) + call EndSpriteMovement + ld hl, $b + add hl, bc + ld [hl], $0 + ld hl, $20 + add hl, bc + ld a, [hl] + call Function4ab7 + ld hl, $a + add hl, bc + ld [hl], e + ld hl, $1e + add hl, bc + ld [hl], a + ld hl, $9 + add hl, bc + ld [hl], $15 + ret + +Function4ab7: ; 4ab7 (1:4ab7) + ld d, a + and $3f + ld e, a + ld a, d + rlca + rlca + and $3 + ld d, a + inc d + ld a, $1 +.asm_4ac4 + dec d + ret z + add a + jr .asm_4ac4 + +Function4ac9: ; 4ac9 (1:4ac9) + call InitStep + call CheckNPCMovementPermissions + jr c, .asm_4af0 + call UpdateGrassPriority + ld hl, $b + add hl, bc + ld [hl], $2 + ld hl, wCenteredObject + ld a, [hConnectionStripLength] + cp [hl] + jr z, .asm_4ae9 + ld hl, $9 + add hl, bc + ld [hl], $7 + ret + +.asm_4ae9 + ld hl, $9 + add hl, bc + ld [hl], $6 + ret + +.asm_4af0 + call EndSpriteMovement + call Function4603 +Function4af6: ; 4af6 (1:4af6) + call Random + ld a, [hRandom] + and $7f + jr asm_4b06 + +Function4aff: ; 4aff (1:4aff) + call Random + ld a, [hRandomAdd] + and $1f +asm_4b06 + ld hl, $a + add hl, bc + ld [hl], a + ld hl, $7 + add hl, bc + ld [hl], $ff + ld hl, $b + add hl, bc + ld [hl], $1 + ld hl, $9 + add hl, bc + ld [hl], $3 + ret diff --git a/engine/step_types.asm b/engine/step_types.asm new file mode 100755 index 00000000..27602b5b --- /dev/null +++ b/engine/step_types.asm @@ -0,0 +1,754 @@ +StepTypesJumptable: ; 4b1e + dw ObjectMovementReset + dw MapObjectMovementPattern + dw Function4e02 + dw Function4db4 + dw Function4df8 + dw Function4de3 + dw Function4e2d + dw Function4e1e + dw Function4b5d + dw Function4b96 + dw Function4e5a + dw Function4dd6 + dw Function4bef + dw Function4c60 + dw Function4ceb + dw Function4ea4 + dw Function4d55 + dw Function4d86 + dw Function4d9f + dw Function4edb + dw Function4f0a + dw Function4f0a + dw Function4f4e + dw Function4f51 + dw Function4dc7 + +Function4b50: ; 4b50 (1:4b50) + ld hl, $a + add hl, bc + dec [hl] + ret nz + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4b5d: ; 4b5d (1:4b5d) + call Object28AnonymousJumptable + dw Function4b64 + dw Function4b80 + +Function4b64: + call AddStepVector + call Function4f7d + ld hl, $a + add hl, bc + dec [hl] + ret nz + call CopyNextCoordsTileToStandingCoordsTile + call GetNextTile + ld hl, $5 + add hl, bc + res 3, [hl] + call IncrementObjectStructField28 + ret + +Function4b80: + call AddStepVector + call Function4f7d + ld hl, $a + add hl, bc + dec [hl] + ret nz + call CopyNextCoordsTileToStandingCoordsTile + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4b96: ; 4b96 (1:4b96) + call Object28AnonymousJumptable + dw Function4ba1 + dw Function4ba9 + dw Function4bc9 + dw Function4bd4 + +Function4ba1: + ld hl, wPlayerStepFlags + set 7, [hl] + call IncrementObjectStructField28 +Function4ba9: + call Function4f7d + call UpdatePlayerStep + ld hl, $a + add hl, bc + dec [hl] + ret nz + call CopyNextCoordsTileToStandingCoordsTile + ld hl, $5 + add hl, bc + res 3, [hl] + ld hl, wPlayerStepFlags + set 6, [hl] + set 4, [hl] + call IncrementObjectStructField28 + ret + +Function4bc9: + call GetNextTile + ld hl, wPlayerStepFlags + set 7, [hl] + call IncrementObjectStructField28 +Function4bd4: + call Function4f7d + call UpdatePlayerStep + ld hl, $a + add hl, bc + dec [hl] + ret nz + ld hl, wPlayerStepFlags + set 6, [hl] + call CopyNextCoordsTileToStandingCoordsTile + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4bef: ; 4bef (1:4bef) + call Object28AnonymousJumptable + dw Function4bfa + dw Function4c09 + dw Function4c19 + dw Function4c34 + +Function4bfa: + ld hl, $c + add hl, bc + ld [hl], $0 + ld hl, $a + add hl, bc + ld [hl], $10 + call IncrementObjectStructField28 +Function4c09: + ld hl, $b + add hl, bc + ld [hl], $4 + ld hl, $a + add hl, bc + dec [hl] + ret nz + call IncrementObjectStructField28 + ret + +Function4c19: + ld hl, $c + add hl, bc + ld [hl], $0 + ld hl, $1f + add hl, bc + ld [hl], $10 + ld hl, $a + add hl, bc + ld [hl], $10 + ld hl, $5 + add hl, bc + res 3, [hl] + call IncrementObjectStructField28 +Function4c34: + ld hl, $b + add hl, bc + ld [hl], $4 + ld hl, $1f + add hl, bc + inc [hl] + ld a, [hl] + ld d, $60 + call Sine + ld a, h + sub $60 + ld hl, $1a + add hl, bc + ld [hl], a + ld hl, $a + add hl, bc + dec [hl] + ret nz + ld hl, $c + add hl, bc + ld [hl], $0 + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4c60: ; 4c60 (1:4c60) + call Object28AnonymousJumptable + dw Function4c71 + dw Function4c81 + dw Function4c8a + dw Function4ca0 + dw Function4cc2 + dw Function4ccc + dw Function4cd8 + +Function4c71: + ld hl, $b + add hl, bc + ld [hl], $0 + ld hl, $a + add hl, bc + ld [hl], $10 + call IncrementObjectStructField28 + ret + +Function4c81: + ld hl, $a + add hl, bc + dec [hl] + ret nz + call IncrementObjectStructField28 +Function4c8a: + ld hl, $c + add hl, bc + ld [hl], $0 + ld hl, $1f + add hl, bc + ld [hl], $0 + ld hl, $a + add hl, bc + ld [hl], $10 + call IncrementObjectStructField28 + ret + +Function4ca0: + ld hl, $b + add hl, bc + ld [hl], $4 + ld hl, $1f + add hl, bc + inc [hl] + ld a, [hl] + ld d, $60 + call Sine + ld a, h + sub $60 + ld hl, $1a + add hl, bc + ld [hl], a + ld hl, $a + add hl, bc + dec [hl] + ret nz + call IncrementObjectStructField28 +Function4cc2: + ld hl, $a + add hl, bc + ld [hl], $10 + call IncrementObjectStructField28 + ret + +Function4ccc: + ld hl, $b + add hl, bc + ld [hl], $4 + ld hl, $a + add hl, bc + dec [hl] + ret nz +Function4cd8: + ld hl, $c + add hl, bc + ld [hl], $0 + ld hl, $1a + add hl, bc + ld [hl], $0 + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4ceb: ; 4ceb (1:4ceb) + call Object28AnonymousJumptable + dw Function4cf6 + dw Function4d05 + dw Function4d26 + dw Function4d42 + +Function4cf6: + ld hl, $b + add hl, bc + ld [hl], $0 + ld hl, $a + add hl, bc + ld [hl], $10 + call IncrementObjectStructField28 +Function4d05: + ld hl, $a + add hl, bc + dec [hl] + ret nz + ld hl, $b + add hl, bc + ld [hl], $2 + ld hl, $c + add hl, bc + ld [hl], $0 + ld hl, $1f + add hl, bc + ld [hl], $0 + ld hl, $a + add hl, bc + ld [hl], $10 + call IncrementObjectStructField28 +Function4d26: + ld hl, $1f + add hl, bc + inc [hl] + ld a, [hl] + ld d, $60 + call Sine + ld a, h + sub $60 + ld hl, $1a + add hl, bc + ld [hl], a + ld hl, $a + add hl, bc + dec [hl] + ret nz + call IncrementObjectStructField28 +Function4d42: + ld hl, $c + add hl, bc + ld [hl], $0 + ld hl, $1a + add hl, bc + ld [hl], $0 + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4d55: ; 4d55 (1:4d55) + call Object28AnonymousJumptable + dw Function4d5c + dw Function4d6b + +Function4d5c: + ld hl, $a + add hl, bc + ld [hl], $8 + ld hl, $1a + add hl, bc + ld [hl], $0 + call IncrementObjectStructField28 +Function4d6b: + ld hl, $1a + add hl, bc + ld a, [hl] + xor $1 + ld [hl], a + ld hl, $a + add hl, bc + dec [hl] + ret nz + ld hl, $1a + add hl, bc + ld [hl], $0 + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4d86: ; 4d86 (1:4d86) + call Function4d8c + jp Function4b50 + +Function4d8c: ; 4d8c (1:4d8c) + ld hl, $a + add hl, bc + ld a, [hl] + and $1 + ld a, $1 + jr z, .asm_4d99 + ld a, $0 +.asm_4d99 + ld hl, $b + add hl, bc + ld [hl], a + ret + +Function4d9f: ; 4d9f (1:4d9f) + ld hl, $a + add hl, bc + ld a, [hl] + and $1 + ld a, $4 + jr z, .asm_4dac + ld a, $5 +.asm_4dac + ld hl, $b + add hl, bc + ld [hl], a + jp Function4b50 + +Function4db4: ; 4db4 (1:4db4) + ld hl, $7 + add hl, bc + ld [hl], $ff + ld hl, $a + add hl, bc + dec [hl] + ret nz + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4dc7: ; 4dc7 (1:4dc7) + ld hl, $7 + add hl, bc + ld [hl], $ff + ld hl, $a + add hl, bc + dec [hl] + ret nz + jp DeleteMapObject + +Function4dd6: ; 4dd6 (1:4dd6) + ld hl, $a + add hl, bc + dec [hl] + ret nz + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4de3: ; 4de3 (1:4de3) + call Object28AnonymousJumptable + dw Function4dea + dw Function4df8 + +Function4dea: + call RestoreDefaultMovement + call GetInitialFacing + ld hl, $8 + add hl, bc + ld [hl], a + call IncrementObjectStructField28 +Function4df8: ; 4df8 (1:4df8) + call Function4f5a + ld hl, $7 + add hl, bc + ld [hl], $ff + ret + +Function4e02: ; 4e02 (1:4e02) + call Function4f5a + call AddStepVector + ld hl, $a + add hl, bc + dec [hl] + ret nz + call CopyNextCoordsTileToStandingCoordsTile + ld hl, $7 + add hl, bc + ld [hl], $ff + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4e1e: ; 4e1e (1:4e1e) + call AddStepVector + ld hl, $a + add hl, bc + dec [hl] + ret nz + call CopyNextCoordsTileToStandingCoordsTile + jp Function4af6 + +Function4e2d: ; 4e2d (1:4e2d) + call Object28AnonymousJumptable + dw Function4e34 + dw Function4e3c + +Function4e34: + ld hl, wPlayerStepFlags + set 7, [hl] + call IncrementObjectStructField28 +Function4e3c: + call UpdatePlayerStep + ld hl, $a + add hl, bc + dec [hl] + ret nz + ld hl, wPlayerStepFlags + set 6, [hl] + call CopyNextCoordsTileToStandingCoordsTile + ld hl, $7 + add hl, bc + ld [hl], $ff + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4e5a: ; 4e5a (1:4e5a) + call Object28AnonymousJumptable + dw Function4e65 + dw Function4e7b + dw Function4e84 + dw Function4e97 + +Function4e65: + ld hl, $7 + add hl, bc + ld [hl], $ff + ld hl, $c + add hl, bc + ld a, [hl] + ld [hl], $2 + ld hl, $a + add hl, bc + ld [hl], $2 + call IncrementObjectStructField28 +Function4e7b: + ld hl, $a + add hl, bc + dec [hl] + ret nz + call IncrementObjectStructField28 +Function4e84: + ld hl, $1d + add hl, bc + ld a, [hl] + ld hl, $8 + add hl, bc + ld [hl], a + ld hl, $a + add hl, bc + ld [hl], $2 + call IncrementObjectStructField28 +Function4e97: + ld hl, $a + add hl, bc + dec [hl] + ret nz + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4ea4: ; 4ea4 (1:4ea4) + call AddStepVector + ld hl, $a + add hl, bc + dec [hl] + ret nz + push bc + ld hl, $10 + add hl, bc + ld d, [hl] + ld hl, $11 + add hl, bc + ld e, [hl] + ld hl, $1 + add hl, bc + ld a, [hl] + ld b, a + ld a, $2 + ld hl, UselessAndA + 1 + rst FarCall + pop bc + ld hl, $5 + add hl, bc + res 2, [hl] + call CopyNextCoordsTileToStandingCoordsTile + ld hl, $7 + add hl, bc + ld [hl], $ff + ld hl, $9 + add hl, bc + ld [hl], $1 + ret + +Function4edb: ; 4edb (1:4edb) + ld hl, $1d + add hl, bc + ld e, [hl] + inc hl + ld d, [hl] + ld hl, $0 + add hl, de + ld a, [hl] + and a + jr z, .asm_4f07 + ld hl, $17 + add hl, de + ld a, [hl] + ld hl, $17 + add hl, bc + ld [hl], a + ld hl, $18 + add hl, de + ld a, [hl] + ld hl, $18 + add hl, bc + ld [hl], a + ld hl, $a + add hl, bc + ld a, [hl] + and a + ret z + dec [hl] + ret nz +.asm_4f07 + jp DeleteMapObject + +Function4f0a: ; 4f0a (1:4f0a) + call Object28AnonymousJumptable + dw Function4f11 + dw Function4f1a + +Function4f11: + xor a + ld hl, $1d + add hl, bc + ld [hl], a + call IncrementObjectStructField28 +Function4f1a: + ld hl, $1d + add hl, bc + ld d, [hl] + ld a, [wPlayerStepVectorY] + sub d + ld [wPlayerStepVectorY], a + ld hl, $a + add hl, bc + dec [hl] + jr z, .asm_4f3f + ld a, [hl] + call Function4f43 + ld hl, $1d + add hl, bc + ld [hl], a + ld d, a + ld a, [wPlayerStepVectorY] + add d + ld [wPlayerStepVectorY], a + ret + +.asm_4f3f + call DeleteMapObject + ret + +Function4f43: ; 4f43 (1:4f43) + ld hl, $1e + add hl, bc + and $1 + ld a, [hl] + ret z + cpl + inc a + ret + +Function4f4e: ; 4f4e (1:4f4e) + call Object28AnonymousJumptable +Function4f51: ; 4f51 (1:4f51) + call Object28AnonymousJumptable + dw Function4f5a + dw Function4f5a + dw Function4f5a + +Function4f5a: ; 4f5a (1:4f5a) + ret + +Function4f5b: + ld hl, $1d + add hl, bc + inc [hl] + ld a, [hl] + srl a + srl a + and $7 + ld l, a + ld h, $0 + ld de, .data + add hl, de + ld a, [hl] + ld hl, $1a + add hl, bc + ld [hl], a + ret + +.data + db 0, -1, -2, -3, -4, -3, -2, -1 + +Function4f7d: ; 4f7d (1:4f7d) + call GetStepVector + ld a, h + ld hl, $1f + add hl, bc + ld e, [hl] + add e + ld [hl], a + nop + srl e + ld d, $0 + ld hl, .data + add hl, de + ld a, [hl] + ld hl, $1a + add hl, bc + ld [hl], a + ret + +.data + db -4, -6, -8, -10, -11, -12, -12, -12 + db -11, -10, -9, -8, -6, -4, 0, 0 + +Function4fa8: + ld a, [wce87] + ld hl, wce88 + ld [hl], a + ld a, $3e + ld [wce87], a + ld a, [hl] + ret + +GetMovementByte: + ld hl, wMovementDataPointerBank + call GetMovementByte_ + ret + +Function4fbd: + ld hl, $1b + add hl, bc + ld e, [hl] + inc [hl] + ld d, $0 + ld hl, wMovementPerson + ld a, [hli] + ld h, [hl] + ld l, a + add hl, de + ld a, [hl] + ret + +Function4fce: + ld hl, $1b + add hl, bc + ld e, [hl] + inc [hl] + ld d, $0 + ld hl, wce8f + ld a, [hli] + ld h, [hl] + ld l, a + add hl, de + ld a, [hl] + ret |