2018-06-24 07:09:41 -07:00
|
|
|
CanObjectMoveInDirection:
|
2015-12-09 15:25:44 -08:00
|
|
|
ld hl, OBJECT_PALETTE
|
|
|
|
add hl, bc
|
2018-05-23 16:10:15 -07:00
|
|
|
bit SWIMMING_F, [hl]
|
|
|
|
jr z, .not_swimming
|
2015-12-09 15:25:44 -08:00
|
|
|
|
|
|
|
ld hl, OBJECT_FLAGS1
|
|
|
|
add hl, bc
|
2022-07-09 14:12:02 -07:00
|
|
|
bit NOCLIP_TILES_F, [hl]
|
2023-07-27 04:01:32 -07:00
|
|
|
jr nz, .noclip_tiles
|
2015-12-09 15:25:44 -08:00
|
|
|
push hl
|
|
|
|
push bc
|
2018-05-23 19:01:21 -07:00
|
|
|
call WillObjectBumpIntoLand
|
2015-12-09 15:25:44 -08:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret c
|
2018-05-23 19:01:21 -07:00
|
|
|
jr .continue
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2018-05-23 16:10:15 -07:00
|
|
|
.not_swimming
|
2015-12-09 15:25:44 -08:00
|
|
|
ld hl, OBJECT_FLAGS1
|
|
|
|
add hl, bc
|
2018-05-23 19:01:21 -07:00
|
|
|
bit NOCLIP_TILES_F, [hl]
|
|
|
|
jr nz, .noclip_tiles
|
2015-12-09 15:25:44 -08:00
|
|
|
push hl
|
|
|
|
push bc
|
2018-05-23 19:01:21 -07:00
|
|
|
call WillObjectBumpIntoWater
|
2015-12-09 15:25:44 -08:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
|
2018-05-23 19:01:21 -07:00
|
|
|
.noclip_tiles
|
|
|
|
.continue
|
|
|
|
bit NOCLIP_OBJS_F, [hl]
|
|
|
|
jr nz, .noclip_objs
|
2015-12-09 15:25:44 -08:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
2017-12-24 10:46:34 -08:00
|
|
|
call WillObjectBumpIntoSomeoneElse
|
2015-12-09 15:25:44 -08:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
|
2018-05-23 19:01:21 -07:00
|
|
|
.noclip_objs
|
|
|
|
bit MOVE_ANYWHERE_F, [hl]
|
|
|
|
jr nz, .move_anywhere
|
2015-12-09 15:25:44 -08:00
|
|
|
push hl
|
2017-12-24 10:46:34 -08:00
|
|
|
call HasObjectReachedMovementLimit
|
2015-12-09 15:25:44 -08:00
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
|
|
|
|
push hl
|
2017-12-24 10:46:34 -08:00
|
|
|
call IsObjectMovingOffEdgeOfScreen
|
2015-12-09 15:25:44 -08:00
|
|
|
pop hl
|
|
|
|
ret c
|
|
|
|
|
2018-05-23 19:01:21 -07:00
|
|
|
.move_anywhere
|
2015-12-09 15:25:44 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WillObjectBumpIntoWater:
|
2020-10-05 08:24:47 -07:00
|
|
|
call CanObjectLeaveTile
|
2015-12-09 15:25:44 -08:00
|
|
|
ret c
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
ld hl, OBJECT_PALETTE
|
|
|
|
add hl, bc
|
2018-01-11 09:00:01 -08:00
|
|
|
bit OAM_PRIORITY, [hl]
|
2020-10-05 08:24:47 -07:00
|
|
|
jp nz, WillObjectRemainOnWater
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld d, a
|
2024-02-10 15:25:25 -08:00
|
|
|
call GetTilePermission
|
2020-02-13 16:01:47 -08:00
|
|
|
and a ; LAND_TILE
|
2018-05-23 19:01:21 -07:00
|
|
|
jr z, WillObjectBumpIntoTile
|
2015-12-09 15:25:44 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WillObjectBumpIntoLand:
|
2020-10-05 08:24:47 -07:00
|
|
|
call CanObjectLeaveTile
|
2015-12-09 15:25:44 -08:00
|
|
|
ret c
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2024-02-10 15:25:25 -08:00
|
|
|
call GetTilePermission
|
2020-02-13 16:01:47 -08:00
|
|
|
cp WATER_TILE
|
2018-05-23 19:01:21 -07:00
|
|
|
jr z, WillObjectBumpIntoTile
|
2015-12-09 15:25:44 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WillObjectBumpIntoTile:
|
2024-02-10 15:25:25 -08:00
|
|
|
ld hl, OBJECT_TILE_COLLISION
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2020-10-05 08:24:47 -07:00
|
|
|
call GetSideWallDirectionMask
|
2015-12-09 15:25:44 -08:00
|
|
|
ret nc
|
|
|
|
push af
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2018-01-16 14:27:50 -08:00
|
|
|
maskbits NUM_DIRECTIONS
|
2015-12-09 15:25:44 -08:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2020-10-05 08:24:47 -07:00
|
|
|
ld hl, .dir_masks
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, de
|
|
|
|
pop af
|
|
|
|
and [hl]
|
|
|
|
ret z
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2020-10-05 08:24:47 -07:00
|
|
|
.dir_masks
|
2019-03-03 10:30:27 -08:00
|
|
|
db DOWN_MASK ; DOWN
|
|
|
|
db UP_MASK ; UP
|
|
|
|
db RIGHT_MASK ; LEFT
|
|
|
|
db LEFT_MASK ; RIGHT
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2020-10-05 08:24:47 -07:00
|
|
|
CanObjectLeaveTile:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_TILE
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2020-10-05 08:24:47 -07:00
|
|
|
call GetSideWallDirectionMask
|
2015-12-09 15:25:44 -08:00
|
|
|
ret nc
|
|
|
|
push af
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
2018-01-16 14:27:50 -08:00
|
|
|
maskbits NUM_DIRECTIONS
|
2015-12-09 15:25:44 -08:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2020-10-05 08:24:47 -07:00
|
|
|
ld hl, .dir_masks
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, de
|
|
|
|
pop af
|
|
|
|
and [hl]
|
|
|
|
ret z
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2020-10-05 08:24:47 -07:00
|
|
|
.dir_masks
|
2019-03-03 10:30:27 -08:00
|
|
|
db UP_MASK ; DOWN
|
|
|
|
db DOWN_MASK ; UP
|
|
|
|
db LEFT_MASK ; LEFT
|
|
|
|
db RIGHT_MASK ; RIGHT
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2020-10-05 08:24:47 -07:00
|
|
|
GetSideWallDirectionMask:
|
2015-12-09 15:25:44 -08:00
|
|
|
ld d, a
|
|
|
|
and $f0
|
2018-06-28 19:35:29 -07:00
|
|
|
cp HI_NYBBLE_SIDE_WALLS
|
2019-03-03 10:30:27 -08:00
|
|
|
jr z, .continue
|
|
|
|
cp HI_NYBBLE_SIDE_BUOYS
|
|
|
|
jr z, .continue
|
2015-12-09 15:25:44 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2019-03-03 10:30:27 -08:00
|
|
|
.continue
|
2015-12-09 15:25:44 -08:00
|
|
|
ld a, d
|
2020-10-05 08:24:47 -07:00
|
|
|
and $7
|
2015-12-09 15:25:44 -08:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2020-10-05 08:24:47 -07:00
|
|
|
ld hl, .side_wall_masks
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2020-10-05 08:24:47 -07:00
|
|
|
.side_wall_masks
|
2019-03-03 10:30:27 -08:00
|
|
|
db RIGHT_MASK ; COLL_RIGHT_WALL/BUOY
|
|
|
|
db LEFT_MASK ; COLL_LEFT_WALL/BUOY
|
|
|
|
db DOWN_MASK ; COLL_UP_WALL/BUOY
|
|
|
|
db UP_MASK ; COLL_DOWN_WALL/BUOY
|
|
|
|
db UP_MASK | RIGHT_MASK ; COLL_DOWN_RIGHT_WALL/BUOY
|
|
|
|
db UP_MASK | LEFT_MASK ; COLL_DOWN_LEFT_WALL/BUOY
|
|
|
|
db DOWN_MASK | RIGHT_MASK ; COLL_UP_RIGHT_WALL/BUOY
|
|
|
|
db DOWN_MASK | LEFT_MASK ; COLL_UP_LEFT_WALL/BUOY
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2020-10-05 08:24:47 -07:00
|
|
|
WillObjectRemainOnWater:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2018-01-16 14:27:50 -08:00
|
|
|
maskbits NUM_DIRECTIONS
|
2018-01-11 09:00:01 -08:00
|
|
|
jr z, .down
|
2015-12-09 15:25:44 -08:00
|
|
|
dec a
|
2018-01-11 09:00:01 -08:00
|
|
|
jr z, .up
|
2015-12-09 15:25:44 -08:00
|
|
|
dec a
|
2018-01-11 09:00:01 -08:00
|
|
|
jr z, .left
|
|
|
|
jr .right
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2018-01-11 09:00:01 -08:00
|
|
|
.down
|
2015-12-09 15:25:44 -08:00
|
|
|
inc e
|
|
|
|
push de
|
|
|
|
inc d
|
2018-01-11 09:00:01 -08:00
|
|
|
jr .continue
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2018-01-11 09:00:01 -08:00
|
|
|
.up
|
2015-12-09 15:25:44 -08:00
|
|
|
push de
|
|
|
|
inc d
|
2018-01-11 09:00:01 -08:00
|
|
|
jr .continue
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2018-01-11 09:00:01 -08:00
|
|
|
.left
|
2015-12-09 15:25:44 -08:00
|
|
|
push de
|
|
|
|
inc e
|
2018-01-11 09:00:01 -08:00
|
|
|
jr .continue
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2018-01-11 09:00:01 -08:00
|
|
|
.right
|
2015-12-09 15:25:44 -08:00
|
|
|
inc d
|
|
|
|
push de
|
|
|
|
inc e
|
|
|
|
|
2018-01-11 09:00:01 -08:00
|
|
|
.continue
|
2024-02-10 15:25:25 -08:00
|
|
|
call GetCoordTileCollision
|
|
|
|
call GetTilePermission
|
2015-12-09 15:25:44 -08:00
|
|
|
pop de
|
2020-02-13 16:01:47 -08:00
|
|
|
and a ; LAND_TILE
|
2018-01-11 09:00:01 -08:00
|
|
|
jr nz, .not_land
|
2024-02-10 15:25:25 -08:00
|
|
|
call GetCoordTileCollision
|
|
|
|
call GetTilePermission
|
2020-02-13 16:01:47 -08:00
|
|
|
and a ; LAND_TILE
|
2018-01-11 09:00:01 -08:00
|
|
|
jr nz, .not_land
|
2015-12-09 15:25:44 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2018-01-11 09:00:01 -08:00
|
|
|
.not_land
|
2015-12-09 15:25:44 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckFacingObject::
|
2015-12-09 15:25:44 -08:00
|
|
|
call GetFacingTileCoord
|
|
|
|
|
|
|
|
; Double the distance for counter tiles.
|
|
|
|
call CheckCounterTile
|
2020-10-05 08:24:47 -07:00
|
|
|
jr nz, .not_counter
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapX]
|
2015-12-09 15:25:44 -08:00
|
|
|
sub d
|
|
|
|
cpl
|
|
|
|
inc a
|
|
|
|
add d
|
|
|
|
ld d, a
|
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapY]
|
2015-12-09 15:25:44 -08:00
|
|
|
sub e
|
|
|
|
cpl
|
|
|
|
inc a
|
|
|
|
add e
|
|
|
|
ld e, a
|
|
|
|
|
2020-10-05 08:24:47 -07:00
|
|
|
.not_counter
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wObjectStructs ; redundant
|
2015-12-09 15:25:44 -08:00
|
|
|
ld a, 0
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh [hMapObjectIndex], a
|
2015-12-09 15:25:44 -08:00
|
|
|
call IsNPCAtCoord
|
|
|
|
ret nc
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_WALKING
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp STANDING
|
|
|
|
jr z, .standing
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.standing
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WillObjectBumpIntoSomeoneElse:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
jr IsNPCAtCoord
|
|
|
|
|
2020-10-05 17:10:01 -07:00
|
|
|
IsObjectFacingSomeoneElse: ; unreferenced
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2015-12-09 15:25:44 -08:00
|
|
|
call GetObjectStruct
|
2020-10-05 17:10:01 -07:00
|
|
|
call .GetFacingCoords
|
2015-12-09 15:25:44 -08:00
|
|
|
call IsNPCAtCoord
|
|
|
|
ret
|
|
|
|
|
2020-10-05 17:10:01 -07:00
|
|
|
.GetFacingCoords:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
call GetSpriteDirection
|
2020-10-05 17:10:01 -07:00
|
|
|
and a ; OW_DOWN?
|
2015-12-09 15:25:44 -08:00
|
|
|
jr z, .down
|
|
|
|
cp OW_UP
|
|
|
|
jr z, .up
|
|
|
|
cp OW_LEFT
|
|
|
|
jr z, .left
|
2020-10-05 17:10:01 -07:00
|
|
|
; OW_RIGHT
|
2015-12-09 15:25:44 -08:00
|
|
|
inc d
|
|
|
|
ret
|
|
|
|
|
|
|
|
.down
|
|
|
|
inc e
|
|
|
|
ret
|
|
|
|
|
|
|
|
.up
|
|
|
|
dec e
|
|
|
|
ret
|
|
|
|
|
|
|
|
.left
|
|
|
|
dec d
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
IsNPCAtCoord:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wObjectStructs
|
2015-12-09 15:25:44 -08:00
|
|
|
xor a
|
|
|
|
.loop
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh [hObjectStructIndex], a
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-12-09 15:25:44 -08:00
|
|
|
jr z, .next
|
|
|
|
|
|
|
|
ld hl, OBJECT_FLAGS1
|
|
|
|
add hl, bc
|
|
|
|
bit 7, [hl]
|
|
|
|
jr nz, .next
|
|
|
|
|
|
|
|
ld hl, OBJECT_PALETTE
|
|
|
|
add hl, bc
|
2018-05-23 16:06:04 -07:00
|
|
|
bit BIG_OBJECT_F, [hl]
|
2020-10-05 17:10:01 -07:00
|
|
|
jr z, .not_big
|
2020-10-05 08:24:47 -07:00
|
|
|
call WillObjectIntersectBigObject
|
2020-10-05 17:10:01 -07:00
|
|
|
jr nc, .check_current_coords
|
|
|
|
jr .continue
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2020-10-05 17:10:01 -07:00
|
|
|
.not_big
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp d
|
2020-10-05 17:10:01 -07:00
|
|
|
jr nz, .check_current_coords
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp e
|
2020-10-05 17:10:01 -07:00
|
|
|
jr nz, .check_current_coords
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2020-10-05 17:10:01 -07:00
|
|
|
.continue
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2015-12-09 15:25:44 -08:00
|
|
|
ld l, a
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hObjectStructIndex]
|
2015-12-09 15:25:44 -08:00
|
|
|
cp l
|
2020-10-05 17:10:01 -07:00
|
|
|
jr nz, .yes
|
2015-12-09 15:25:44 -08:00
|
|
|
|
2020-10-05 17:10:01 -07:00
|
|
|
.check_current_coords
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_X
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp d
|
|
|
|
jr nz, .next
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_Y
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp e
|
|
|
|
jr nz, .next
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hMapObjectIndex]
|
2015-12-09 15:25:44 -08:00
|
|
|
ld l, a
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hObjectStructIndex]
|
2015-12-09 15:25:44 -08:00
|
|
|
cp l
|
2020-10-05 17:10:01 -07:00
|
|
|
jr nz, .yes
|
2015-12-09 15:25:44 -08:00
|
|
|
|
|
|
|
.next
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hObjectStructIndex]
|
2015-12-09 15:25:44 -08:00
|
|
|
inc a
|
|
|
|
cp NUM_OBJECT_STRUCTS
|
|
|
|
jr nz, .loop
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2020-10-05 17:10:01 -07:00
|
|
|
.yes
|
2015-12-09 15:25:44 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HasObjectReachedMovementLimit:
|
2015-12-09 15:25:44 -08:00
|
|
|
ld hl, OBJECT_RADIUS
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr z, .nope
|
|
|
|
and $f
|
|
|
|
jr z, .check_y
|
|
|
|
ld e, a
|
|
|
|
ld d, a
|
|
|
|
ld hl, OBJECT_INIT_X
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
sub d
|
|
|
|
ld d, a
|
|
|
|
ld a, [hl]
|
|
|
|
add e
|
|
|
|
ld e, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp d
|
|
|
|
jr z, .yes
|
|
|
|
cp e
|
|
|
|
jr z, .yes
|
|
|
|
|
|
|
|
.check_y
|
|
|
|
ld hl, OBJECT_RADIUS
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
jr z, .nope
|
|
|
|
ld e, a
|
|
|
|
ld d, a
|
|
|
|
ld hl, OBJECT_INIT_Y
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
sub d
|
|
|
|
ld d, a
|
|
|
|
ld a, [hl]
|
|
|
|
add e
|
|
|
|
ld e, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp d
|
|
|
|
jr z, .yes
|
|
|
|
cp e
|
|
|
|
jr z, .yes
|
|
|
|
|
|
|
|
.nope
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.yes
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
IsObjectMovingOffEdgeOfScreen:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wXCoord]
|
2015-12-09 15:25:44 -08:00
|
|
|
cp [hl]
|
|
|
|
jr z, .check_y
|
|
|
|
jr nc, .yes
|
|
|
|
add $9
|
|
|
|
cp [hl]
|
|
|
|
jr c, .yes
|
|
|
|
|
|
|
|
.check_y
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wYCoord]
|
2015-12-09 15:25:44 -08:00
|
|
|
cp [hl]
|
|
|
|
jr z, .nope
|
|
|
|
jr nc, .yes
|
|
|
|
add $8
|
|
|
|
cp [hl]
|
|
|
|
jr c, .yes
|
|
|
|
|
|
|
|
.nope
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.yes
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2020-10-05 17:10:01 -07:00
|
|
|
IsNPCAtPlayerCoord: ; unreferenced
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapX]
|
2015-12-09 15:25:44 -08:00
|
|
|
ld d, a
|
2022-09-12 06:15:44 -07:00
|
|
|
ld a, [wPlayerMapY]
|
2015-12-09 15:25:44 -08:00
|
|
|
ld e, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wObjectStructs
|
2015-12-09 15:25:44 -08:00
|
|
|
xor a
|
|
|
|
.loop
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh [hObjectStructIndex], a
|
2016-05-04 19:34:09 -07:00
|
|
|
call DoesObjectHaveASprite
|
2015-12-09 15:25:44 -08:00
|
|
|
jr z, .next
|
2020-10-05 17:10:01 -07:00
|
|
|
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MOVEMENT_TYPE
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2018-01-30 19:34:05 -08:00
|
|
|
cp SPRITEMOVEDATA_BIGDOLLSYM
|
2020-10-05 17:10:01 -07:00
|
|
|
jr nz, .not_big
|
2020-10-05 08:24:47 -07:00
|
|
|
call WillObjectIntersectBigObject
|
2015-12-09 15:25:44 -08:00
|
|
|
jr c, .yes
|
|
|
|
jr .next
|
|
|
|
|
2020-10-05 17:10:01 -07:00
|
|
|
.not_big
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp e
|
|
|
|
jr nz, .check_current_coords
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp d
|
|
|
|
jr nz, .check_current_coords
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hObjectStructIndex]
|
2019-03-03 10:30:27 -08:00
|
|
|
cp PLAYER_OBJECT
|
2015-12-09 15:25:44 -08:00
|
|
|
jr z, .next
|
|
|
|
jr .yes
|
|
|
|
|
|
|
|
.check_current_coords
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_Y
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp e
|
|
|
|
jr nz, .next
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_LAST_MAP_X
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
cp d
|
|
|
|
jr nz, .next
|
|
|
|
jr .yes
|
|
|
|
|
|
|
|
.next
|
2019-11-03 09:25:59 -08:00
|
|
|
ld hl, OBJECT_LENGTH
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2020-12-23 13:54:28 -08:00
|
|
|
ldh a, [hObjectStructIndex]
|
2015-12-09 15:25:44 -08:00
|
|
|
inc a
|
|
|
|
cp NUM_OBJECT_STRUCTS
|
|
|
|
jr nz, .loop
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.yes
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2020-10-05 08:24:47 -07:00
|
|
|
WillObjectIntersectBigObject:
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_X
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, d
|
|
|
|
sub [hl]
|
|
|
|
jr c, .nope
|
2020-10-05 08:24:47 -07:00
|
|
|
cp 2 ; big doll width
|
2015-12-09 15:25:44 -08:00
|
|
|
jr nc, .nope
|
2022-09-12 06:15:44 -07:00
|
|
|
ld hl, OBJECT_MAP_Y
|
2015-12-09 15:25:44 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, e
|
|
|
|
sub [hl]
|
|
|
|
jr c, .nope
|
2020-10-05 08:24:47 -07:00
|
|
|
cp 2 ; big doll height
|
2015-12-09 15:25:44 -08:00
|
|
|
jr nc, .nope
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.nope
|
|
|
|
and a
|
|
|
|
ret
|