[Decompilation] [th04] Bullets: Sprite selection by angle

Part of P0150, funded by Blue Bolt.
This commit is contained in:
nmlgc 2021-06-24 20:46:39 +02:00
parent 81c3de0057
commit 4cbeadde96
4 changed files with 12 additions and 20 deletions

View File

@ -419,3 +419,12 @@ void near bullet_template_speedtune_for_playperf(void)
bullet_template.speed.set(0.5f);
}
}
static const unsigned char ANGLE_PER_SPRITE = (0x80 / BULLET_D_CELS);
unsigned char pascal near bullet_patnum_for_angle(unsigned char angle)
{
return (
((angle + (ANGLE_PER_SPRITE / 2) - 1) & (0x80 - 1)) / ANGLE_PER_SPRITE
);
}

View File

@ -107,7 +107,7 @@ void pascal near bullet_update_patnum(bullet_t near *bullet);
// Returns the offset for a directional bullet sprite that shows the given
// [angle].
int pascal near bullet_patnum_for_angle(unsigned char angle);
unsigned char pascal near bullet_patnum_for_angle(unsigned char angle);
// Turns every 4th bullet into a point item when zapping bullets.
extern bool bullet_zap_drop_point_items;

View File

@ -1,17 +0,0 @@
public BULLET_PATNUM_FOR_ANGLE
bullet_patnum_for_angle proc near
@@angle = byte ptr 4
push bp
mov bp, sp
mov al, [bp+@@angle]
mov ah, 0
add ax, 3
and ax, 7Fh
mov bx, 8
cwd
idiv bx
pop bp
retn 2
bullet_patnum_for_angle endp

View File

@ -28228,8 +28228,8 @@ main_033_TEXT segment byte public 'CODE' use16
BULLET_VELOCITY_AND_ANGLE_SET procdesc pascal near \
i:word
_bullet_template_speedtune_for_pl procdesc near
include th04/main/bullet/patnum_for_angle.asm
BULLET_PATNUM_FOR_ANGLE procdesc pascal near \
angle:byte
; =============== S U B R O U T I N E =======================================