ReC98/th04/player/shots_add.asm

29 lines
575 B
NASM

; Searches and returns the next free shot slot, or NULL if there are no more
; free ones.
; shot_t* pascal 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