diff options
author | PikalaxALT <PikalaxALT@gmail.com> | 2015-11-09 23:01:45 -0500 |
---|---|---|
committer | PikalaxALT <PikalaxALT@gmail.com> | 2015-11-09 23:01:45 -0500 |
commit | f1b2466cc3672fa72f5b43e96a634dd83796f047 (patch) | |
tree | 817f959ae8a7527b65f76e6800ccad84535436ae /home/movement.asm | |
parent | 77d0a8a39696f28a78450225d60d1149f554ad88 (diff) |
Cleaning up static HRAM labels; movement stuff, route 38 trainers
Diffstat (limited to 'home/movement.asm')
-rw-r--r-- | home/movement.asm | 88 |
1 files changed, 52 insertions, 36 deletions
diff --git a/home/movement.asm b/home/movement.asm index 82486b5c1..fdb606bd5 100644 --- a/home/movement.asm +++ b/home/movement.asm @@ -1,29 +1,29 @@ -Function1b1e:: ; 1b1e - ld [wd003], a +InitMovementBuffer:: ; 1b1e + ld [wMovementBufferPerson], a xor a - ld [DefaultFlypoint], a - ld a, $0 + ld [wMovementBufferCount], a + ld a, $0 ; useless ld [wd004], a ld a, $7 - ld [StartFlypoint], a + ld [wd005], a ld a, $d0 - ld [EndFlypoint], a + ld [wd006], a ret ; 1b35 -Function1b35:: ; 1b35 - ld a, [DefaultFlypoint] +DecrementMovementBufferCount:: ; 1b35 + ld a, [wMovementBufferCount] and a ret z dec a - ld [DefaultFlypoint], a + ld [wMovementBufferCount], a ret ; 1b3f -Function1b3f:: ; 1b3f +AppendToMovementBuffer:: ; 1b3f push hl push de - ld hl, DefaultFlypoint + ld hl, wMovementBufferCount ld e, [hl] inc [hl] ld d, 0 @@ -35,47 +35,50 @@ Function1b3f:: ; 1b3f ret ; 1b50 -Function1b50:: ; 1b50 +AppendToMovementBufferNTimes:: ; 1b50 push af ld a, c and a - jr nz, .asm_1b57 + jr nz, .okay pop af ret -.asm_1b57 +.okay pop af -.asm_1b58 - call Function1b3f +.loop + call AppendToMovementBuffer dec c - jr nz, .asm_1b58 + jr nz, .loop ret ; 1b5f -Function1b5f:: ; 1b5f +ComputePathToWalkToPlayer:: ; 1b5f push af +; compare x coords, load left/right into h, and x distance into d ld a, b sub d - ld h, $2 - jr nc, .asm_1b6a + ld h, LEFT + jr nc, .got_x_distance dec a cpl - ld h, $3 + ld h, RIGHT -.asm_1b6a +.got_x_distance ld d, a +; compare y coords, load up/down into l, and y distance into e ld a, c sub e - ld l, $1 - jr nc, .asm_1b75 + ld l, UP + jr nc, .got_y_distance dec a cpl - ld l, $0 + ld l, DOWN -.asm_1b75 +.got_y_distance ld e, a +; if the x distance is less than the y distance, swap h and l, and swap d and e cp d - jr nc, .asm_1b7f + jr nc, .done ld a, h ld h, l ld l, a @@ -83,21 +86,23 @@ Function1b5f:: ; 1b5f ld d, e ld e, a -.asm_1b7f +.done pop af ld b, a +; Add movement in the longer direction first... ld a, h - call Function1b92 + call .GetMovementData ld c, d - call Function1b50 + call AppendToMovementBufferNTimes +; ... then add the shorter direction. ld a, l - call Function1b92 + call .GetMovementData ld c, e - call Function1b50 + call AppendToMovementBufferNTimes ret ; 1b92 -Function1b92:: ; 1b92 +.GetMovementData: ; 1b92 push de push hl ld l, b @@ -108,7 +113,7 @@ endr ld e, a ld d, 0 add hl, de - ld de, .data_1ba5 + ld de, .MovementData add hl, de ld a, [hl] pop hl @@ -116,8 +121,19 @@ endr ret ; 1ba5 -.data_1ba5 - db 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 +.MovementData + slow_step_down + slow_step_up + slow_step_left + slow_step_right + step_down + step_up + step_left + step_right + big_step_down + big_step_up + big_step_left + big_step_right ; 1bb1 Function1bb1:: ; 1bb1 |