mirror of
https://github.com/open-goal/jak-project
synced 2026-09-12 20:56:09 -04:00
up to collide-probe
This commit is contained in:
@@ -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"}));
|
||||
|
||||
Reference in New Issue
Block a user