mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
[merc] support up to 64 effects (#2292)
This commit is contained in:
parent
2c12a4e00b
commit
d6bd437ea1
|
@ -235,13 +235,19 @@ void Merc2::handle_pc_model(const DmaTransfer& setup,
|
|||
input_data += 128 + 16 * i;
|
||||
|
||||
// Next part is some flags
|
||||
auto* flags = (const u32*)input_data;
|
||||
int num_effects = flags[0]; // mostly just a sanity check
|
||||
struct PcMercFlags {
|
||||
u64 enable_mask;
|
||||
u64 ignore_alpha_mask;
|
||||
u8 effect_count;
|
||||
u8 update_verts;
|
||||
};
|
||||
auto* flags = (const PcMercFlags*)input_data;
|
||||
int num_effects = flags->effect_count; // mostly just a sanity check
|
||||
ASSERT(num_effects < kMaxEffect);
|
||||
u32 current_ignore_alpha_bits = flags[1]; // shader settings
|
||||
u32 current_effect_enable_bits = flags[2]; // mask for game to disable an effect
|
||||
bool model_uses_mod = flags[3]; // if we should update vertices from game.
|
||||
input_data += 16;
|
||||
u64 current_ignore_alpha_bits = flags->ignore_alpha_mask; // shader settings
|
||||
u64 current_effect_enable_bits = flags->enable_mask; // mask for game to disable an effect
|
||||
bool model_uses_mod = flags->update_verts; // if we should update vertices from game.
|
||||
input_data += 32;
|
||||
|
||||
// Next is "fade data", indicating the color/intensity of envmap effect
|
||||
u8 fade_buffer[4 * kMaxEffect];
|
||||
|
@ -461,7 +467,7 @@ void Merc2::handle_pc_model(const DmaTransfer& setup,
|
|||
// loop over effects, creating draws for each
|
||||
for (size_t ei = 0; ei < model->effects.size(); ei++) {
|
||||
// game has disabled it?
|
||||
if (!(current_effect_enable_bits & (1 << ei))) {
|
||||
if (!(current_effect_enable_bits & (1ull << ei))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -470,7 +476,7 @@ void Merc2::handle_pc_model(const DmaTransfer& setup,
|
|||
continue;
|
||||
}
|
||||
|
||||
u8 ignore_alpha = (current_ignore_alpha_bits & (1 << ei));
|
||||
bool ignore_alpha = !!(current_ignore_alpha_bits & (1ull << ei));
|
||||
auto& effect = model->effects[ei];
|
||||
|
||||
bool should_envmap = effect.has_envmap;
|
||||
|
|
|
@ -76,8 +76,8 @@ class GlowRenderer {
|
|||
|
||||
// max sprites should be 128 in simple sprite, plus 256 from aux = 384
|
||||
// 20 width = 20 * 20 = 400 sprites > 384.
|
||||
// we multiply by 4 to get 16x as many max sprites (in-game the max is only 12x)
|
||||
static constexpr int kDownsampleBatchWidth = 20 * 4;
|
||||
// we multiply by 2 to get 4x as many max sprites (in-game the max is 4x)
|
||||
static constexpr int kDownsampleBatchWidth = 20 * 2;
|
||||
static constexpr int kMaxSprites = kDownsampleBatchWidth * kDownsampleBatchWidth;
|
||||
static constexpr int kMaxVertices = kMaxSprites * 32; // check.
|
||||
static constexpr int kMaxIndices = kMaxSprites * 32; // check.
|
||||
|
|
|
@ -941,9 +941,17 @@
|
|||
;; lights (7 qw x 1)
|
||||
;; matrix slot string (128 char, 8 qw)
|
||||
;; matrices (7 qw x N)
|
||||
;; flags (num-effects, effect-alpha-ignore, effect-disable)
|
||||
;; flags 2 qw
|
||||
;; fades (u32 x N), padding to qw aligned
|
||||
|
||||
(deftype pc-merc-flags (structure)
|
||||
((enable-mask uint64)
|
||||
(ignore-alpha-mask uint64)
|
||||
(effect-count uint8)
|
||||
(update-verts uint8)
|
||||
)
|
||||
)
|
||||
|
||||
(defun pc-merc-draw-request ((dc draw-control) (dma-buf pointer) (matrix-buf pointer) (update-verts symbol))
|
||||
(let ((start-packet (the-as dma-packet dma-buf))
|
||||
(qwc-total 0))
|
||||
|
@ -1024,14 +1032,14 @@
|
|||
)
|
||||
|
||||
;; flags
|
||||
(let ((flags (the (pointer uint32) dma-buf)))
|
||||
(set! (-> flags 0) (-> merc-ctrl header effect-count))
|
||||
(set! (-> flags 1) ignore-alpha-mask)
|
||||
(set! (-> flags 2) enable-mask)
|
||||
(set! (-> flags 3) (if update-verts 1 0))
|
||||
(let ((flags (the (pc-merc-flags) dma-buf)))
|
||||
(set! (-> flags effect-count) (-> merc-ctrl header effect-count))
|
||||
(set! (-> flags update-verts) (if update-verts 1 0))
|
||||
(set! (-> flags enable-mask) enable-mask)
|
||||
(set! (-> flags ignore-alpha-mask) ignore-alpha-mask)
|
||||
)
|
||||
(&+! dma-buf (* 16 1))
|
||||
(+! qwc-total 1)
|
||||
(&+! dma-buf (* 16 2))
|
||||
(+! qwc-total 2)
|
||||
|
||||
;; fades
|
||||
(let ((fades (the (pointer uint32) dma-buf)))
|
||||
|
|
|
@ -630,6 +630,14 @@
|
|||
)
|
||||
)
|
||||
|
||||
(deftype pc-merc-flags (structure)
|
||||
((enable-mask uint64)
|
||||
(ignore-alpha-mask uint64)
|
||||
(effect-count uint8)
|
||||
(update-verts uint8)
|
||||
)
|
||||
)
|
||||
|
||||
(defun pc-merc-draw-request ((dc draw-control) (dma-buf pointer) (matrix-buf pointer) (tex-idx int) (update-verts symbol))
|
||||
"Send a request to PC Merc2 to draw the given object.
|
||||
Only draws the effects which match this texture index.
|
||||
|
@ -720,14 +728,14 @@
|
|||
)
|
||||
|
||||
;; flags
|
||||
(let ((flags (the (pointer uint32) dma-buf)))
|
||||
(set! (-> flags 0) (-> merc-ctrl header effect-count))
|
||||
(set! (-> flags 1) ignore-alpha-mask)
|
||||
(set! (-> flags 2) enable-mask)
|
||||
(set! (-> flags 3) (if update-verts 1 0))
|
||||
(let ((flags (the (pc-merc-flags) dma-buf)))
|
||||
(set! (-> flags effect-count) (-> merc-ctrl header effect-count))
|
||||
(set! (-> flags update-verts) (if update-verts 1 0))
|
||||
(set! (-> flags enable-mask) enable-mask)
|
||||
(set! (-> flags ignore-alpha-mask) ignore-alpha-mask)
|
||||
)
|
||||
(&+! dma-buf (* 16 1))
|
||||
(+! qwc-total 1)
|
||||
(&+! dma-buf (* 16 2))
|
||||
(+! qwc-total 2)
|
||||
|
||||
;; fades
|
||||
(let ((fades (the (pointer uint32) dma-buf)))
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
(define-extern sprite-glow-draw (function dma-buffer none))
|
||||
|
||||
(#when PC_BIG_MEMORY (defconstant SPRITE_MAX_AMOUNT_MULT 12))
|
||||
(#when PC_BIG_MEMORY (defconstant SPRITE_AUX_MAX_AMOUNT_MULT 4))
|
||||
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ the sprite renderer draw 2D or 3D sprites
|
|||
(defmethod new sprite-aux-list ((allocation symbol) (type-to-make type) (size int))
|
||||
|
||||
(#when PC_BIG_MEMORY
|
||||
(*! size SPRITE_MAX_AMOUNT_MULT))
|
||||
(*! size SPRITE_AUX_MAX_AMOUNT_MULT))
|
||||
|
||||
(let ((v0-0 (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* size 16))))))
|
||||
(set! (-> v0-0 num-entries) size)
|
||||
|
|
Loading…
Reference in a new issue