up to collide-probe

This commit is contained in:
water111
2026-08-31 15:10:16 -07:00
parent 0de650cd31
commit 251b0659cb
21 changed files with 3466 additions and 4730 deletions
+32
View File
@@ -313,6 +313,38 @@ TEST(Demacro, Jak1RecognizesDmaCntPacketsWithExplicitQwc) {
)");
}
TEST(Demacro, Jak1RecognizesDirectDmaCntAndRefPackets) {
const auto rules =
demacro::load_rules(file_util::get_file_path({"decompiler/config/jak1/demacro.jsonc"}));
const std::string source = R"((begin
(let ((packet (the-as object (-> dma-buf base))))
(set! (-> (the-as dma-packet packet) dma) (new 'static 'dma-tag :id (dma-tag-id cnt)))
(set! (-> (the-as dma-packet packet) vif0) vif0)
(set! (-> (the-as dma-packet packet) vif1) vif1)
(set! (-> dma-buf base) (&+ (the-as pointer packet) 16)))
(let* ((dma-state dma-buf)
(packet (the-as object (-> dma-state base))))
(set! (-> (the-as dma-packet packet) dma)
(new 'static 'dma-tag :id (dma-tag-id cnt) :qwc qwc))
(set! (-> (the-as dma-packet packet) vif0) vif0)
(set! (-> (the-as dma-packet packet) vif1) vif1)
(set! (-> dma-state base) (&+ (the-as pointer packet) 16)))
(let ((packet (the-as object (-> dma-buf base))))
(set! (-> (the-as dma-packet packet) dma)
(new 'static 'dma-tag :qwc qwc :id (dma-tag-id ref) :addr addr))
(set! (-> (the-as dma-packet packet) vif0) vif0)
(set! (-> (the-as dma-packet packet) vif1) vif1)
(set! (-> dma-buf base) (&+ (the-as pointer packet) 16))))
)";
const auto result = demacro::rewrite(source, rules);
EXPECT_EQ(result.rewrite_count(), 3);
EXPECT_EQ(result.source, R"((begin
(dma-buffer-add-cnt-vif2 dma-buf 0 vif0 vif1)
(dma-buffer-add-cnt-vif2 dma-buf qwc vif0 vif1)
(dma-buffer-add-ref-vif2 dma-buf qwc addr vif0 vif1))
)");
}
TEST(Demacro, Jak1RecognizesDmaNextPackets) {
const auto rules =
demacro::load_rules(file_util::get_file_path({"decompiler/config/jak1/demacro.jsonc"}));