diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp index fbe62621..6d0af09f 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp @@ -38,7 +38,6 @@ namespace ams::ldr::oc::pcv::mariko { void CalculateMiscTimings() { tW2P = 0x2d; rdv = 0x39 + C.mem_burst_read_latency; - obdly = 0x10000002 + C.mem_burst_write_latency; einput_duration = 0x1C; quse_width = 0x8; @@ -48,7 +47,6 @@ namespace ams::ldr::oc::pcv::mariko { rdv += e.rdv_inc; if (e.einput) einput_duration = e.einput; if (e.quse_width) quse_width = e.quse_width; - obdly += e.obdly_delta; } } @@ -69,6 +67,14 @@ namespace ams::ldr::oc::pcv::mariko { } } + void CalculateObdly() { + obdly = 0x10000002 + C.mem_burst_write_latency; + + if (auto patch = FindObdlyPatch()) { + obdly += patch->adjust; + } + } + void CalculateTWTPDEN() { tWTPDEN = tW2P + 1 + CEIL(tDQSS_max / tCK_avg) + CEIL(tDQS2DQ_max / tCK_avg) + 6; if (C.marikoEmcMaxClock >= 2'233'000 && C.marikoEmcMaxClock < 2'533'000) tWTPDEN++; @@ -165,6 +171,7 @@ namespace ams::ldr::oc::pcv::mariko { void CalculateTimings() { CalculateMiscTimings(); CalculateIbdly(); + CalculateObdly(); CalculateTWTPDEN(); CalculateTR2W(); CalculateTW2R(); diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/timing_tables.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/timing_tables.cpp index 4fc9c3e2..1fba3679 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/timing_tables.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/timing_tables.cpp @@ -146,6 +146,37 @@ namespace ams::ldr::oc::pcv::mariko { return nullptr; } + const AdjustPatch g_obdly_patches[] = { + {2'533'000, -2}, + {2'566'000, -2}, + {2'600'000, -2}, + {2'633'000, -2}, + {2'666'000, -2}, + {2'700'000, -2}, + {2'733'000, -2}, + {2'766'000, -2}, + {2'800'000, -2}, + {2'833'000, -4}, + {2'866'000, -2}, + {2'900'000, -4}, + {2'933'000, -2}, + {2'966'000, -2}, + {3'000'000, -2}, + {3'033'000, -2}, + {3'066'000, -2}, + {3'100'000, -4}, + {3'133'000, -4}, + }; + + const u32 g_obdly_table_size = sizeof(g_obdly_patches) / sizeof(g_obdly_patches[0]); + + const AdjustPatch *FindObdlyPatch() { + for (u32 i = 0; i < g_obdly_table_size; i++) + if (g_obdly_patches[i].freq == C.marikoEmcMaxClock) + return &g_obdly_patches[i]; + return nullptr; + } + const AdjustPatch g_tr2w_patches[] = { {2'500'000, 1}, {2'533'000, 1}, diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/timing_tables.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/timing_tables.hpp index 11a49b3a..ad5a9fa2 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/timing_tables.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/timing_tables.hpp @@ -41,6 +41,10 @@ namespace ams::ldr::oc::pcv::mariko { extern const u32 g_ibdly_table_size; const AdjustPatch *FindIbdlyPatch(); + extern const AdjustPatch g_obdly_patches[]; + extern const u32 g_obdly_table_size; + const AdjustPatch *FindObdlyPatch(); + extern const AdjustPatch g_tr2w_patches[]; extern const u32 g_tr2w_table_size; const AdjustPatch *FindTR2WPatch();