diff options
-rwxr-xr-x | engine/map_objects.asm | 594 | ||||
-rw-r--r-- | home/battle.asm | 8 | ||||
-rw-r--r-- | main.asm | 16 |
3 files changed, 603 insertions, 15 deletions
diff --git a/engine/map_objects.asm b/engine/map_objects.asm index ab9bac58..05138129 100755 --- a/engine/map_objects.asm +++ b/engine/map_objects.asm @@ -123,7 +123,7 @@ Function4442: bit 5, [hl] jr nz, .asm_4427 .asm_4415 - call Function47b6 + call MapObjectMovementPattern ld hl, $9 add hl, bc ld a, [hl] @@ -132,7 +132,7 @@ Function4442: cp $1 ret z .asm_4422 - ld hl, $4b1e + ld hl, StepTypesJumptable rst JumpTable ret @@ -474,10 +474,592 @@ SetValueObjectStructField28: ld [hl], a ret -ObjectMovementReset: - dr $4795, $47b6 -Function47b6: - dr $47b6, $557f +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 + +StepTypesJumptable: ; 4b1e + dr $4b1e, $4fdf +Function4fdf: + dr $4fdf, $4fe9 +Function4fe9: + dr $4fe9, $53b1 +Function53b1: + dr $53b1, $54d7 +Function54d7: + dr $54d7, $557f Function557f:: dr $557f, $5730 Function5730:: diff --git a/home/battle.asm b/home/battle.asm index df80a1f7..d7d56dda 100644 --- a/home/battle.asm +++ b/home/battle.asm @@ -101,12 +101,8 @@ RefreshBattleHuds:: jp WaitBGMap UpdateBattleHuds:: ; 3bf8 (0:3bf8) - ld a, $f - ld hl, $5da9 - rst FarCall - ld a, $f - ld hl, $5e97 - rst FarCall + callba UpdatePlayerHUD + callba UpdateEnemyHUD ret GetBattleVar:: @@ -64,7 +64,9 @@ CheckNickErrors:: ; 677e Multiply_:: ; 67bd dr $67bd, $681d Divide_:: ; 681d - dr $681d, $754e + dr $681d, $6fa0 +CheckNPCMovementPermissions: ; 6fa0 + dr $6fa0, $754e ENDC IF DEF(SILVER) @@ -80,7 +82,9 @@ CheckNickErrors:: ; 6744 Multiply_:: ; 6783 dr $6783, $67e3 Divide_:: ; 67e3 - dr $67e3, $7514 + dr $67e3, $6f66 +CheckNPCMovementPermissions: ; 6f66 + dr $6f66, $7514 ENDC SECTION "bank2", ROMX, BANK[$2] @@ -217,7 +221,13 @@ Battle_GetTrainerName:: ; 398f2 dr $398f2, $3c000 SECTION "bankf", ROMX, BANK[$f] - dr $3c000, $3ec11 + dr $3c000, $3dda9 + +UpdatePlayerHUD:: + dr $3dda9, $3de97 + +UpdateEnemyHUD:: + dr $3de97, $3ec11 BattleRandom_:: ; 3ec11 dr $3ec11, $40000 |