[Decompilation] [th05] Bullets: Sprite selection for angled bullets

Hopelessly hardcoded.

Part of P0184, funded by -Tom-.
This commit is contained in:
nmlgc 2022-02-20 11:20:21 +01:00
parent 8ff719da91
commit 9471e133e9
4 changed files with 28 additions and 54 deletions

View File

@ -164,11 +164,14 @@ static const subpixel_t BULLET_KILLBOX_H = TO_SP(8);
# define PELLET_COUNT 180
# define BULLET16_COUNT 220
// Returns the patnum for the directional or vector bullet sprite starting at
// [patnum_base] that shows the given [angle].
int pascal near bullet_patnum_for_angle(int patnum_base, unsigned char angle);
// Updates [bullet]'s patnum based on its current angle.
void pascal near bullet_update_patnum(bullet_t near &bullet);
// Returns the sprite ID of a directional or vector bullet sprite that
// represents the given [angle], relative to [patnum_base]. While the function
// is technically not restricted to `main_patnum_t` in TH05 and can also be
// used for a general (angle / BULLET_D_CELS) division, it still assumes
// [patnum_base] to be that type in order to distinguish vector bullets.
unsigned char pascal near bullet_patnum_for_angle(
int patnum_base, unsigned char angle
);
// Turns every 4th bullet into a point item when zapping bullets.
extern bool bullet_zap_drop_point_items;

View File

@ -30,6 +30,26 @@ extern "C" {
#include "th05/sprites/main_pat.h"
static const int SLOWDOWN_BULLET_THRESHOLD_UNUSED = 32;
// Updates [bullet]'s patnum based on its current angle.
void pascal near bullet_update_patnum(bullet_t near &bullet)
{
unsigned char patnum_base; // main_patnum_t, obviously
if(bullet.patnum < PAT_BULLET16_D) {
return;
}
if(bullet.patnum < (PAT_BULLET16_D_BLUE_last + 1)) {
patnum_base = PAT_BULLET16_D_BLUE;
} else if(bullet.patnum < (PAT_BULLET16_D_GREEN_last + 1)) {
patnum_base = PAT_BULLET16_D_GREEN;
} else if(bullet.patnum < (PAT_BULLET16_V_RED_last + 1)) {
patnum_base = PAT_BULLET16_V_RED;
} else {
patnum_base = PAT_BULLET16_V_BLUE;
}
bullet.patnum = bullet_patnum_for_angle(patnum_base, bullet.angle);
}
#else
#include "th04/sprites/main_pat.h"

View File

@ -1,48 +0,0 @@
public BULLET_UPDATE_PATNUM
bullet_update_patnum proc near
@@patnum_base = byte ptr -1
@@bullet = word ptr 4
push bp
mov bp, sp
sub sp, 2
push si
mov si, [bp+@@bullet]
cmp [si+bullet_t.BULLET_patnum], PAT_BULLET16_D_BLUE
jl short @@ret
cmp [si+bullet_t.BULLET_patnum], PAT_BULLET16_D_GREEN
jge short @@d_green?
mov [bp+@@patnum_base], PAT_BULLET16_D_BLUE
jmp short @@set
; ---------------------------------------------------------------------------
@@d_green?:
cmp [si+bullet_t.BULLET_patnum], PAT_BULLET16_V_RED
jge short @@v_red?
mov [bp+@@patnum_base], PAT_BULLET16_D_GREEN
jmp short @@set
; ---------------------------------------------------------------------------
@@v_red?:
cmp [si+bullet_t.BULLET_patnum], PAT_BULLET16_V_BLUE
jge short @@v_blue?
mov [bp+@@patnum_base], PAT_BULLET16_V_RED
jmp short @@set
; ---------------------------------------------------------------------------
@@v_blue?:
mov [bp+@@patnum_base], PAT_BULLET16_V_BLUE
@@set:
mov al, [bp+@@patnum_base]
mov ah, 0
call bullet_patnum_for_angle pascal, ax, word ptr [si+bullet_t.BULLET_angle]
mov ah, 0
mov [si+bullet_t.BULLET_patnum], ax
@@ret:
pop si
leave
retn 2
bullet_update_patnum endp

View File

@ -11594,7 +11594,6 @@ loc_178A5:
curvebullets_update endp
include th04/main/item/splashes_update.asm
include th05/main/bullet/update_patnum.asm
extern _bullets_update:proc
main_033_TEXT ends