Fix generic2 zbuffer and jak3 progress menu crash (#4091)
Fix Generic2 bug where a tricky way to disable z-buffer writing wasn't being detected. This should fix some lightning or other effects: <img width="968" height="982" alt="image" src="https://github.com/user-attachments/assets/cf3225c1-9ea4-45ed-86e3-2ad3b9a6b1ee" /> Also fixed an original game issue(?) where a hud box could be used uninitialized . Sometimes this would end up drawing a really large box area which would overflow the DMA buffer and cause confusing crashes.
This commit is contained in:
parent
06d40b5f85
commit
5681aa64a5
|
|
@ -200,6 +200,13 @@ void Generic2::determine_draw_modes(bool enable_at, bool default_fog) {
|
|||
current_mode.set_alpha_test(DrawMode::AlphaTest::ALWAYS);
|
||||
current_mode.disable_depth_write();
|
||||
}
|
||||
|
||||
// another way to disable z-writing:
|
||||
if (current_mode.get_alpha_test() == DrawMode::AlphaTest::NEVER &&
|
||||
current_mode.get_alpha_fail() == GsTest::AlphaFail::FB_ONLY) {
|
||||
current_mode.set_alpha_test(DrawMode::AlphaTest::ALWAYS);
|
||||
current_mode.disable_depth_write();
|
||||
}
|
||||
}
|
||||
|
||||
m_adgifs[i].mode = current_mode;
|
||||
|
|
|
|||
|
|
@ -569,7 +569,10 @@ void Generic2::process_dma_prim(DmaFollower& dma, u32 next_bucket) {
|
|||
auto direct_setup = dma.read_and_advance();
|
||||
ASSERT(direct_setup.size_bytes == 32 && direct_setup.vifcode0().kind == VifCode::Kind::NOP &&
|
||||
direct_setup.vifcode1().kind == VifCode::Kind::DIRECT);
|
||||
m_drawing_config.zmsk = false;
|
||||
u64* u64s = (u64*)direct_setup.data;
|
||||
ASSERT(u64s[3] == (u64)GsRegisterAddress::ZBUF_1);
|
||||
GsZbuf buf(u64s[2]);
|
||||
m_drawing_config.zmsk = buf.zmsk();
|
||||
m_drawing_config.uses_full_matrix = true;
|
||||
|
||||
// STYCYCL to set up generic VU1 constants
|
||||
|
|
@ -617,6 +620,9 @@ void Generic2::process_dma_prim(DmaFollower& dma, u32 next_bucket) {
|
|||
frag->uses_hud = false;
|
||||
auto* adgif = &next_adgif();
|
||||
memcpy(&adgif->data, up1.data + Generic2::FRAG_HEADER_SIZE, sizeof(AdGifData));
|
||||
// printf("tex0: %lx, tex1: %lx, mip %lx, clamp %lx, alpha %lx\n", adgif->data.tex0_addr,
|
||||
// adgif->data.tex1_addr, adgif->data.mip_addr, adgif->data.clamp_addr,
|
||||
// adgif->data.alpha_addr);
|
||||
// (new 'static 'gif-tag-regs-32 :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2
|
||||
// (gif-reg-id xyzf2))
|
||||
int num_vtx = up2.size_bytes / (16 * 3);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ extern size_t PrintBufSize; // added
|
|||
constexpr u32 DEBUG_MESSAGE_BUFFER_SIZE = 0x80000;
|
||||
constexpr u32 DEBUG_OUTPUT_BUFFER_SIZE = 0x80000;
|
||||
constexpr u32 DEBUG_PRINT_BUFFER_SIZE = 0x200000;
|
||||
constexpr u32 PRINT_BUFFER_SIZE = 0x20000; // upped from 0x2000 on PS2 because we ran out of memory
|
||||
constexpr u32 PRINT_BUFFER_SIZE = 0x40000; // upped from 0x2000 on PS2 because we ran out of memory
|
||||
|
||||
struct format_struct {
|
||||
char data[0x40];
|
||||
|
|
|
|||
|
|
@ -1494,7 +1494,13 @@
|
|||
)
|
||||
)
|
||||
(progress-method-34 self)
|
||||
(end-scan sv-216 (-> self scanlines-alpha))
|
||||
|
||||
;; og:preserve-this
|
||||
;; calling end-scan without calling begin-scan will use uninitialized stack memory
|
||||
;; for box parameters, which may draw a large number of lines and overflow DMA memory.
|
||||
(if sv-220
|
||||
(end-scan sv-216 (-> self scanlines-alpha))
|
||||
)
|
||||
)
|
||||
(when (and (< 0.8 (-> self anim-frame)) (or (= (-> self current) 'bigmap) (= (-> self next) 'bigmap)))
|
||||
(progress-method-33 self (-> *progress-work* full-screen))
|
||||
|
|
|
|||
|
|
@ -386,7 +386,12 @@
|
|||
)
|
||||
)
|
||||
(progress-method-34 self)
|
||||
(end-scan sv-216 (-> self scanlines-alpha))
|
||||
;; og:preserve-this
|
||||
;; calling end-scan without calling begin-scan will use uninitialized stack memory
|
||||
;; for box parameters, which may draw a large number of lines and overflow DMA memory.
|
||||
(if sv-220
|
||||
(end-scan sv-216 (-> self scanlines-alpha))
|
||||
)
|
||||
)
|
||||
(when (and (< 0.8 (-> self anim-frame)) (or (= (-> self current) 'bigmap) (= (-> self next) 'bigmap)))
|
||||
(progress-method-33 self (-> *progress-work* full-screen))
|
||||
|
|
|
|||
Loading…
Reference in New Issue