ReC98/th04/shots_add.asm

29 lines
571 B
NASM

; Searches and returns the next free shot slot, or NULL if there are no more
; free ones.
; shot_t* shots_add(void);
public _shots_add
_shots_add proc near
xor ax, ax
@@loop:
cmp _shot_last_id, SHOT_COUNT
jnb short @@ret
mov bx, _shot_ptr
add _shot_ptr, size shot_t
cmp [bx+shot_t.flag], 0
jz short @@found
inc _shot_last_id
jmp short @@loop
@@found:
mov word ptr [bx+shot_t.flag], 1
mov eax, player_pos.cur
mov dword ptr [bx+shot_t.pos.cur], eax
mov dword ptr [bx+shot_t.pos.velocity], (-12 shl 4) shl 16 or (0)
mov ax, bx
@@ret:
retn
_shots_add endp