summaryrefslogtreecommitdiff
path: root/engine/overworld
diff options
context:
space:
mode:
authorobskyr <powpowd@gmail.com>2018-07-07 03:49:57 +0200
committerobskyr <powpowd@gmail.com>2018-07-07 03:49:57 +0200
commitd4bb6b990a94de27f58d2c92fad5888017d3bb9d (patch)
tree7ae791db3412dbe7f9393d0c204ab4426a4992c4 /engine/overworld
parentd3f356a1dc6970973932502edbe3af6b150a22d0 (diff)
parentf3f0e711bf4f4205fd29f2b448c93ff5597507e5 (diff)
Merge branch 'master' of https://github.com/pret/pokegold-spaceworld
Diffstat (limited to 'engine/overworld')
-rw-r--r--[-rwxr-xr-x]engine/overworld/object_collision.asm314
-rwxr-xr-xengine/overworld/spawn_points.asm118
2 files changed, 216 insertions, 216 deletions
diff --git a/engine/overworld/object_collision.asm b/engine/overworld/object_collision.asm
index a04000b..8d42a93 100755..100644
--- a/engine/overworld/object_collision.asm
+++ b/engine/overworld/object_collision.asm
@@ -1,157 +1,157 @@
-INCLUDE "constants.asm"
-
-SECTION "GetSpritesNextTile", ROMX[$774a], BANK[$01]
-
-; Get the tile that the sprite will walk onto next
-GetSpritesNextTile: ; 01:774a
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld d, [hl]
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld e, [hl]
- push bc
- call GetCoordTile
- pop bc
- ret
-
-; Sets carry flag if the object (bc) next tile is a collision
-_IsObjectCollisionTileSolid: ; 01:775a
- call GetSpritesNextTile
- ld e, a
- ld d, 0
- ld hl, CollisionTypeTable
- add hl, de
- ld a, BANK(CollisionTypeTable)
- call GetFarByte
- and ALWAYS_SOLID ; also covers SOMETIMES_SOLID
- ret z
- scf
- ret
-
-
-
-SECTION "_CheckObjectCollision", ROMX[$77dd], BANK[$01]
-
-; returns the carry flag if a sprite is at coords d, e
-; will not collide with sprite index stored in hEventCollisionException
-_CheckObjectCollision: ; 01:77dd
- ld bc, wObjectStructs
- xor a
-.loop
- ldh [hObjectStructIndexBuffer], a
- ld hl, OBJECT_SPRITE
- add hl, bc
- ld a, [hl]
- and a
- jr z, .next
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld a, [hl]
- cp d
- jr nz, .check_last_position
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld a, [hl]
- cp e
- jr nz, .check_last_position
- ldh a, [hEventCollisionException]
- ld l, a
- ldh a, [hObjectStructIndexBuffer]
- cp l
- jr nz, .collision
-.check_last_position
- ld hl, OBJECT_MAP_X
- add hl, bc
- ld a, [hl]
- cp d
- jr nz, .next
- ld hl, OBJECT_MAP_Y
- add hl, bc
- ld a, [hl]
- cp e
- jr nz, .next
- ldh a, [hEventCollisionException]
- ld l, a
- ldh a, [hObjectStructIndexBuffer]
- cp l
- jr nz, .collision
-.next
- ld hl, OBJECT_LENGTH
- add hl, bc
- ld b, h
- ld c, l
- ldh a, [hObjectStructIndexBuffer]
- inc a
- cp NUM_OBJECT_STRUCTS
- jr nz, .loop
- and a
- ret
-
-.collision
- scf
- ret
-
-SECTION "_CheckPlayerObjectCollision", ROMX[$7894], BANK[$01]
-
-; Sets the carry flag if the player will collide with another sprite's current or next position
-_CheckPlayerObjectCollision: ; 01:7894
- ld a, [wPlayerNextMapX]
- ld d, a
- ld a, [wPlayerNextMapY]
- ld e, a
- ld bc, wObjectStructs
- xor a
-
-.loop
- ldh [hObjectStructIndexBuffer], a
- ld hl, OBJECT_SPRITE
- add hl, bc
- ld a, [hl]
- and a
- jr z, .next
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, bc
- ld a, [hl]
- cp e
- jr nz, .check_last_position
- ld hl, OBJECT_NEXT_MAP_X
- add hl, bc
- ld a, [hl]
- cp d
- jr nz, .check_last_position
-
-; skip the player sprite
- ldh a, [hObjectStructIndexBuffer]
- cp PLAYER_OBJECT_INDEX
- jr z, .next
- jr .collision
-
-.check_last_position
- ld hl, OBJECT_MAP_Y
- add hl, bc
- ld a, [hl]
- cp e
- jr nz, .next
- ld hl, OBJECT_MAP_X
- add hl, bc
- ld a, [hl]
- cp d
- jr nz, .next
- jr .collision
-
-.next
- ld hl, OBJECT_LENGTH
- add hl, bc
- ld b, h
- ld c, l
- ldh a, [hObjectStructIndexBuffer]
- inc a
- cp NUM_OBJECT_STRUCTS
- jr nz, .loop
- xor a
- ret
-
-.collision
- scf
- ret
+INCLUDE "constants.asm"
+
+SECTION "GetSpritesNextTile", ROMX[$774a], BANK[$01]
+
+; Get the tile that the sprite will walk onto next
+GetSpritesNextTile: ; 01:774a
+ ld hl, OBJECT_NEXT_MAP_X
+ add hl, bc
+ ld d, [hl]
+ ld hl, OBJECT_NEXT_MAP_Y
+ add hl, bc
+ ld e, [hl]
+ push bc
+ call GetCoordTile
+ pop bc
+ ret
+
+; Sets carry flag if the object (bc) next tile is a collision
+_IsObjectCollisionTileSolid: ; 01:775a
+ call GetSpritesNextTile
+ ld e, a
+ ld d, 0
+ ld hl, CollisionTypeTable
+ add hl, de
+ ld a, BANK(CollisionTypeTable)
+ call GetFarByte
+ and ALWAYS_SOLID ; also covers SOMETIMES_SOLID
+ ret z
+ scf
+ ret
+
+
+
+SECTION "_CheckObjectCollision", ROMX[$77dd], BANK[$01]
+
+; returns the carry flag if a sprite is at coords d, e
+; will not collide with sprite index stored in hEventCollisionException
+_CheckObjectCollision: ; 01:77dd
+ ld bc, wObjectStructs
+ xor a
+.loop
+ ldh [hObjectStructIndexBuffer], a
+ ld hl, OBJECT_SPRITE
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .next
+ ld hl, OBJECT_NEXT_MAP_X
+ add hl, bc
+ ld a, [hl]
+ cp d
+ jr nz, .check_last_position
+ ld hl, OBJECT_NEXT_MAP_Y
+ add hl, bc
+ ld a, [hl]
+ cp e
+ jr nz, .check_last_position
+ ldh a, [hEventCollisionException]
+ ld l, a
+ ldh a, [hObjectStructIndexBuffer]
+ cp l
+ jr nz, .collision
+.check_last_position
+ ld hl, OBJECT_MAP_X
+ add hl, bc
+ ld a, [hl]
+ cp d
+ jr nz, .next
+ ld hl, OBJECT_MAP_Y
+ add hl, bc
+ ld a, [hl]
+ cp e
+ jr nz, .next
+ ldh a, [hEventCollisionException]
+ ld l, a
+ ldh a, [hObjectStructIndexBuffer]
+ cp l
+ jr nz, .collision
+.next
+ ld hl, OBJECT_LENGTH
+ add hl, bc
+ ld b, h
+ ld c, l
+ ldh a, [hObjectStructIndexBuffer]
+ inc a
+ cp NUM_OBJECT_STRUCTS
+ jr nz, .loop
+ and a
+ ret
+
+.collision
+ scf
+ ret
+
+SECTION "_CheckPlayerObjectCollision", ROMX[$7894], BANK[$01]
+
+; Sets the carry flag if the player will collide with another sprite's current or next position
+_CheckPlayerObjectCollision: ; 01:7894
+ ld a, [wPlayerNextMapX]
+ ld d, a
+ ld a, [wPlayerNextMapY]
+ ld e, a
+ ld bc, wObjectStructs
+ xor a
+
+.loop
+ ldh [hObjectStructIndexBuffer], a
+ ld hl, OBJECT_SPRITE
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .next
+ ld hl, OBJECT_NEXT_MAP_Y
+ add hl, bc
+ ld a, [hl]
+ cp e
+ jr nz, .check_last_position
+ ld hl, OBJECT_NEXT_MAP_X
+ add hl, bc
+ ld a, [hl]
+ cp d
+ jr nz, .check_last_position
+
+; skip the player sprite
+ ldh a, [hObjectStructIndexBuffer]
+ cp PLAYER_OBJECT_INDEX
+ jr z, .next
+ jr .collision
+
+.check_last_position
+ ld hl, OBJECT_MAP_Y
+ add hl, bc
+ ld a, [hl]
+ cp e
+ jr nz, .next
+ ld hl, OBJECT_MAP_X
+ add hl, bc
+ ld a, [hl]
+ cp d
+ jr nz, .next
+ jr .collision
+
+.next
+ ld hl, OBJECT_LENGTH
+ add hl, bc
+ ld b, h
+ ld c, l
+ ldh a, [hObjectStructIndexBuffer]
+ inc a
+ cp NUM_OBJECT_STRUCTS
+ jr nz, .loop
+ xor a
+ ret
+
+.collision
+ scf
+ ret
diff --git a/engine/overworld/spawn_points.asm b/engine/overworld/spawn_points.asm
index c159a21..2476c46 100755
--- a/engine/overworld/spawn_points.asm
+++ b/engine/overworld/spawn_points.asm
@@ -1,59 +1,59 @@
-INCLUDE "constants.asm"
-
-SECTION "LoadSpawnPoint", ROMX[$4791], BANK[$03]
-
-LoadSpawnPoint: ; 03:4791
-; loads the spawn point in wDefaultSpawnPoint
- push hl
- push de
- ld a, [wDefaultSpawnPoint]
- and a
- jr z, .skip
- dec a
- ld l, a
- ld h, 0
- add hl, hl
- add hl, hl
- ld de, SpawnPoints
- add hl, de
- ld a, [hli]
- ld [wMapGroup], a
- ld a, [hli]
- ld [wMapId], a
- ld a, [hli]
- ld [wXCoord], a
- ld a, [hli]
- ld [wYCoord], a
-.skip
- pop de
- pop hl
- ret
-
-IsSpawnPoint: ; 03:47b6
-; Checks if the map loaded in de is a spawn point.
-; Returns carry if it's a spawn point.
- ld hl, SpawnPoints
- ld c, 1
-.loop
- ld a, [hl]
- cp SPAWN_N_A
- jr z, .fail
- cp d
- jr nz, .next
- inc hl
- ld a, [hld]
- cp e
- jr z, .succeed
-.next
- push bc
- ld bc, SPAWN_POINT_SIZE
- add hl, bc
- pop bc
- inc c
- jr .loop
-.fail
- and a
- ret
-.succeed
- scf
- ret
+INCLUDE "constants.asm"
+
+SECTION "LoadSpawnPoint", ROMX[$4791], BANK[$03]
+
+LoadSpawnPoint: ; 03:4791
+; loads the spawn point in wDefaultSpawnPoint
+ push hl
+ push de
+ ld a, [wDefaultSpawnPoint]
+ and a
+ jr z, .skip
+ dec a
+ ld l, a
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ ld de, SpawnPoints
+ add hl, de
+ ld a, [hli]
+ ld [wMapGroup], a
+ ld a, [hli]
+ ld [wMapId], a
+ ld a, [hli]
+ ld [wXCoord], a
+ ld a, [hli]
+ ld [wYCoord], a
+.skip
+ pop de
+ pop hl
+ ret
+
+IsSpawnPoint: ; 03:47b6
+; Checks if the map loaded in de is a spawn point.
+; Returns carry if it's a spawn point.
+ ld hl, SpawnPoints
+ ld c, 1
+.loop
+ ld a, [hl]
+ cp SPAWN_N_A
+ jr z, .fail
+ cp d
+ jr nz, .next
+ inc hl
+ ld a, [hld]
+ cp e
+ jr z, .succeed
+.next
+ push bc
+ ld bc, SPAWN_POINT_SIZE
+ add hl, bc
+ pop bc
+ inc c
+ jr .loop
+.fail
+ and a
+ ret
+.succeed
+ scf
+ ret