2015-11-10 04:01:45 +00:00
|
|
|
InitMovementBuffer:: ; 1b1e
|
2017-12-24 18:46:34 +00:00
|
|
|
ld [wMovementBufferObject], a
|
2013-11-26 11:44:05 +00:00
|
|
|
xor a
|
2015-11-10 04:01:45 +00:00
|
|
|
ld [wMovementBufferCount], a
|
|
|
|
ld a, $0 ; useless
|
2017-12-10 00:41:03 +00:00
|
|
|
ld [wUnusedMovementBufferBank], a
|
2016-03-02 03:31:21 +00:00
|
|
|
ld a, MovementBuffer % $100
|
2017-12-10 00:41:03 +00:00
|
|
|
ld [wUnusedMovementBufferPointer], a
|
2016-03-02 03:31:21 +00:00
|
|
|
ld a, MovementBuffer / $100
|
2017-12-10 00:41:03 +00:00
|
|
|
ld [wUnusedMovementBufferPointer + 1], a
|
2013-11-26 11:44:05 +00:00
|
|
|
ret
|
|
|
|
; 1b35
|
|
|
|
|
2015-11-10 04:01:45 +00:00
|
|
|
DecrementMovementBufferCount:: ; 1b35
|
|
|
|
ld a, [wMovementBufferCount]
|
2013-11-26 11:44:05 +00:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
dec a
|
2015-11-10 04:01:45 +00:00
|
|
|
ld [wMovementBufferCount], a
|
2013-11-26 11:44:05 +00:00
|
|
|
ret
|
|
|
|
; 1b3f
|
|
|
|
|
2015-11-10 04:01:45 +00:00
|
|
|
AppendToMovementBuffer:: ; 1b3f
|
2013-11-26 11:44:05 +00:00
|
|
|
push hl
|
|
|
|
push de
|
2015-11-10 04:01:45 +00:00
|
|
|
ld hl, wMovementBufferCount
|
2013-11-26 11:44:05 +00:00
|
|
|
ld e, [hl]
|
|
|
|
inc [hl]
|
|
|
|
ld d, 0
|
|
|
|
ld hl, MovementBuffer
|
|
|
|
add hl, de
|
|
|
|
ld [hl], a
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 1b50
|
|
|
|
|
2015-11-10 04:01:45 +00:00
|
|
|
AppendToMovementBufferNTimes:: ; 1b50
|
2013-11-26 11:44:05 +00:00
|
|
|
push af
|
|
|
|
ld a, c
|
|
|
|
and a
|
2015-11-10 04:01:45 +00:00
|
|
|
jr nz, .okay
|
2013-11-26 11:44:05 +00:00
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2015-11-10 04:01:45 +00:00
|
|
|
.okay
|
2013-11-26 11:44:05 +00:00
|
|
|
pop af
|
2015-11-10 04:01:45 +00:00
|
|
|
.loop
|
|
|
|
call AppendToMovementBuffer
|
2013-11-26 11:44:05 +00:00
|
|
|
dec c
|
2015-11-10 04:01:45 +00:00
|
|
|
jr nz, .loop
|
2013-11-26 11:44:05 +00:00
|
|
|
ret
|
|
|
|
; 1b5f
|
|
|
|
|
2015-11-10 04:01:45 +00:00
|
|
|
ComputePathToWalkToPlayer:: ; 1b5f
|
2013-11-26 11:44:05 +00:00
|
|
|
push af
|
2015-11-10 04:01:45 +00:00
|
|
|
; compare x coords, load left/right into h, and x distance into d
|
2013-11-26 11:44:05 +00:00
|
|
|
ld a, b
|
|
|
|
sub d
|
2015-11-10 04:01:45 +00:00
|
|
|
ld h, LEFT
|
|
|
|
jr nc, .got_x_distance
|
2013-11-26 11:44:05 +00:00
|
|
|
dec a
|
|
|
|
cpl
|
2015-11-10 04:01:45 +00:00
|
|
|
ld h, RIGHT
|
2013-11-26 11:44:05 +00:00
|
|
|
|
2015-11-10 04:01:45 +00:00
|
|
|
.got_x_distance
|
2013-11-26 11:44:05 +00:00
|
|
|
ld d, a
|
2015-11-10 04:01:45 +00:00
|
|
|
; compare y coords, load up/down into l, and y distance into e
|
2013-11-26 11:44:05 +00:00
|
|
|
ld a, c
|
|
|
|
sub e
|
2015-11-10 04:01:45 +00:00
|
|
|
ld l, UP
|
|
|
|
jr nc, .got_y_distance
|
2013-11-26 11:44:05 +00:00
|
|
|
dec a
|
|
|
|
cpl
|
2015-11-10 04:01:45 +00:00
|
|
|
ld l, DOWN
|
2013-11-26 11:44:05 +00:00
|
|
|
|
2015-11-10 04:01:45 +00:00
|
|
|
.got_y_distance
|
2013-11-26 11:44:05 +00:00
|
|
|
ld e, a
|
2015-11-10 04:01:45 +00:00
|
|
|
; if the x distance is less than the y distance, swap h and l, and swap d and e
|
2013-11-26 11:44:05 +00:00
|
|
|
cp d
|
2015-11-10 04:01:45 +00:00
|
|
|
jr nc, .done
|
2013-11-26 11:44:05 +00:00
|
|
|
ld a, h
|
|
|
|
ld h, l
|
|
|
|
ld l, a
|
|
|
|
ld a, d
|
|
|
|
ld d, e
|
|
|
|
ld e, a
|
|
|
|
|
2015-11-10 04:01:45 +00:00
|
|
|
.done
|
2013-11-26 11:44:05 +00:00
|
|
|
pop af
|
|
|
|
ld b, a
|
2015-11-10 04:01:45 +00:00
|
|
|
; Add movement in the longer direction first...
|
2013-11-26 11:44:05 +00:00
|
|
|
ld a, h
|
2015-11-10 04:01:45 +00:00
|
|
|
call .GetMovementData
|
2013-11-26 11:44:05 +00:00
|
|
|
ld c, d
|
2015-11-10 04:01:45 +00:00
|
|
|
call AppendToMovementBufferNTimes
|
|
|
|
; ... then add the shorter direction.
|
2013-11-26 11:44:05 +00:00
|
|
|
ld a, l
|
2015-11-10 04:01:45 +00:00
|
|
|
call .GetMovementData
|
2013-11-26 11:44:05 +00:00
|
|
|
ld c, e
|
2015-11-10 04:01:45 +00:00
|
|
|
call AppendToMovementBufferNTimes
|
2013-11-26 11:44:05 +00:00
|
|
|
ret
|
|
|
|
; 1b92
|
|
|
|
|
2015-11-10 04:01:45 +00:00
|
|
|
.GetMovementData: ; 1b92
|
2013-11-26 11:44:05 +00:00
|
|
|
push de
|
|
|
|
push hl
|
|
|
|
ld l, b
|
|
|
|
ld h, 0
|
|
|
|
add hl, hl
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, hl
|
2013-11-26 11:44:05 +00:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
add hl, de
|
2015-11-10 04:01:45 +00:00
|
|
|
ld de, .MovementData
|
2013-11-26 11:44:05 +00:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
; 1ba5
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.MovementData:
|
2016-05-14 17:46:14 +00:00
|
|
|
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
|
2013-11-26 11:44:05 +00:00
|
|
|
; 1bb1
|
|
|
|
|
2015-12-23 19:00:29 +00:00
|
|
|
SetMenuAttributes:: ; 1bb1
|
2013-11-26 11:44:05 +00:00
|
|
|
push hl
|
|
|
|
push bc
|
2015-12-17 18:49:26 +00:00
|
|
|
ld hl, w2DMenuCursorInitY
|
2013-11-26 11:44:05 +00:00
|
|
|
ld b, $8
|
2015-11-19 04:16:25 +00:00
|
|
|
.loop
|
2013-11-26 11:44:05 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
dec b
|
2015-11-19 04:16:25 +00:00
|
|
|
jr nz, .loop
|
2013-11-26 11:44:05 +00:00
|
|
|
ld a, $1
|
|
|
|
ld [hli], a
|
2016-05-04 15:46:23 +00:00
|
|
|
ld [hli], a
|
2013-11-26 11:44:05 +00:00
|
|
|
xor a
|
|
|
|
ld [hli], a
|
2016-05-10 16:31:49 +00:00
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
2013-11-26 11:44:05 +00:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 1bc9
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
StaticMenuJoypad:: ; 1bc9
|
2017-12-24 17:47:30 +00:00
|
|
|
callfar _StaticMenuJoypad
|
2015-12-15 23:59:49 +00:00
|
|
|
call GetMenuJoypad
|
2013-11-26 11:44:05 +00:00
|
|
|
ret
|
|
|
|
; 1bd3
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
ScrollingMenuJoypad:: ; 1bd3
|
2017-12-24 17:47:30 +00:00
|
|
|
callfar _ScrollingMenuJoypad
|
2015-12-15 23:59:49 +00:00
|
|
|
call GetMenuJoypad
|
2013-11-26 11:44:05 +00:00
|
|
|
ret
|
|
|
|
; 1bdd
|
|
|
|
|
2015-12-15 23:59:49 +00:00
|
|
|
GetMenuJoypad:: ; 1bdd
|
2013-11-26 11:44:05 +00:00
|
|
|
push bc
|
|
|
|
push af
|
2015-10-16 17:35:43 +00:00
|
|
|
ld a, [hJoyLast]
|
|
|
|
and D_PAD
|
2013-11-26 11:44:05 +00:00
|
|
|
ld b, a
|
|
|
|
ld a, [hJoyPressed]
|
2015-10-16 17:35:43 +00:00
|
|
|
and BUTTONS
|
2013-11-26 11:44:05 +00:00
|
|
|
or b
|
|
|
|
ld b, a
|
|
|
|
pop af
|
|
|
|
ld a, b
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 1bee
|
|
|
|
|
2015-12-18 03:31:16 +00:00
|
|
|
PlaceHollowCursor:: ; 1bee
|
2015-12-15 23:59:49 +00:00
|
|
|
ld hl, wCursorCurrentTile
|
2013-11-26 11:44:05 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [hl], "▷"
|
2013-11-26 11:44:05 +00:00
|
|
|
ret
|
|
|
|
; 1bf7
|
|
|
|
|
2015-12-18 03:31:16 +00:00
|
|
|
HideCursor:: ; 1bf7
|
2015-12-15 23:59:49 +00:00
|
|
|
ld hl, wCursorCurrentTile
|
2013-11-26 11:44:05 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-12-15 23:59:49 +00:00
|
|
|
ld [hl], " "
|
2013-11-26 11:44:05 +00:00
|
|
|
ret
|
|
|
|
; 1c00
|
|
|
|
|