aboutsummaryrefslogtreecommitdiff
path: root/entity/utils.gbasm
diff options
context:
space:
mode:
Diffstat (limited to 'entity/utils.gbasm')
-rw-r--r--entity/utils.gbasm39
1 files changed, 39 insertions, 0 deletions
diff --git a/entity/utils.gbasm b/entity/utils.gbasm
index 8394f9f..592b473 100644
--- a/entity/utils.gbasm
+++ b/entity/utils.gbasm
@@ -106,3 +106,42 @@ Entity_idx_to_entity_list_ptr: ; loaded idx in A, return in BC
POP DE
RET
+
+Spawn_object: ; Texture in D, XY in BC, jump table thingy in E
+ CALL =RNG_Step
+ AND $03
+ CP $00
+ JR NZ, =.skip_spawn_loot
+ PUSH HL
+ CALL =Find_Free_Object_slot
+ LD A, $80
+ CP L
+ JR Z, =.skip_spawn_loot_pop_hl
+
+ LD A, D
+ LD (HL+), A
+ LD A, B
+ LD (HL+), A
+ LD A, C
+ LD (HL+), A
+ CALL =Check_other_object_collision
+ CP $00
+ JR NZ, =.skip_spawn_loot_pop_hl
+ LD A, L
+ AND $f8
+ ADD $03
+ LD L, A
+ LD (HL), E
+
+ ; set the object load counter to the object so it doesn't take 16 frames to load it
+ LD A, L
+ SRA A
+ SRA A
+ SRA A
+ SUB $01
+ LD $mem_object_load_counter, A
+
+ .skip_spawn_loot_pop_hl:
+ POP HL
+ .skip_spawn_loot:
+ RET