Advertisement
Guest User

DMG PPU TIMING

a guest
May 4th, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. DMG PPU timings - rounded to next M cycle, so accurate to 4 clocks
  2.  
  3. StatUpdate() means check LY == LYC (or skip and set LY comparision flag to 0 if ly_for_comparison is -1) and test interrupts for mode_for_interrupt
  4. Similar to ly, mode_for_interrupt = -1 will clear the interrupt line
  5.  
  6. Note: All STAT mode changes are delayed by 1 M-cycle, so if you change to mode 3 on cycle 76 it won't show as mode 3 until cycle 80
  7.  
  8. Glitched line 0 (LCD just switched on)
  9. 0 ly_for_comparison = 0;
  10. StatMode = 0;
  11. mode_for_interrupt = -1;
  12. StatUpdate();
  13.  
  14. oam_read_blocked = false;
  15. oam_write_blocked = false;
  16. vram_read_blocked = false;
  17. vram_write_blocked = false;
  18.  
  19. 76 StatUpdate(); // Note, this is *before* the mode change; mode is still -1 here
  20.  
  21. StatMode = 3;
  22. mode_for_interrupt = 3; // No STAT INT fired for this
  23.  
  24. 80 oam_read_blocked = true;
  25. oam_write_blocked = true;
  26. vram_read_blocked = true;
  27. vram_write_blocked = true;
  28.  
  29. 84 Mode 3 - 164 cycles here (172 total from cycle 76), but length varies
  30.  
  31. 248 StatMode = 0;
  32. mode_for_interrupt = 0;
  33.  
  34. 252 StatUpdate();
  35.  
  36. oam_read_blocked = false;
  37. oam_write_blocked = false;
  38. vram_read_blocked = false;
  39. vram_write_blocked = false;
  40.  
  41. 452 mode_for_interrupt = 2;
  42.  
  43. Lines 0 to 143
  44. 0 LY = current_line;
  45.  
  46. StatMode = 0;
  47. // The OAM STAT interrupt occurs 1 M-cycle before STAT actually changes, except on line 0
  48. if (current_line != 0)
  49. {
  50. mode_for_interrupt = 2;
  51. ly_for_comparison = -1;
  52. }
  53. else // Line 0
  54. {
  55. ly_for_comparison = 0;
  56. }
  57.  
  58. StatUpdate();
  59.  
  60. oam_read_blocked = true;
  61. oam_write_blocked = false;
  62.  
  63. StatMode = 2;
  64. mode_for_interrupt = 2;
  65.  
  66. 4 ly_for_comparison = current_line;
  67. StatUpdate();
  68.  
  69. mode_for_interrupt = -1;
  70. StatUpdate();
  71.  
  72. oam_write_blocked = true;
  73.  
  74. OAM SEARCH (80 cycles)
  75.  
  76. 80 StatMode = 3
  77. mode_for_interrupt = 3;
  78.  
  79. 84 StatUpdate(); // There is no STAT mode 3 INT so this clears interrupt line
  80.  
  81. oam_read_blocked = true;
  82. oam_write_blocked = true;
  83. vram_read_blocked = true;
  84. vram_write_blocked = true;
  85.  
  86. 88 Mode 3 - 164 cycles here (172 total from cycle 80), but length varies
  87.  
  88. 252 StatMode = 0;
  89. mode_for_interrupt = 0;
  90.  
  91. 256 StatUpdate();
  92.  
  93. oam_read_blocked = false;
  94. oam_write_blocked = false;
  95. vram_read_blocked = false;
  96. vram_write_blocked = false;
  97.  
  98. 456 mode_for_interrupt = 2;
  99. current_line++;
  100.  
  101. LOOP BACK TO 0
  102.  
  103. Lines 144 - 152
  104. 0 LY = current_line;
  105. ly_for_comparison = -1;
  106.  
  107. if (current_line == 144)
  108. {
  109. mode_for_interrupt = 2; // Should we really be firing OAM STAT here?
  110. }
  111.  
  112. StatUpdate();
  113.  
  114. 4 ly_for_comparison = current_line;
  115.  
  116. if (current_line == 144)
  117. {
  118. IF |= 1;
  119.  
  120. StatMode = 1;
  121. // Entering VBlank state also triggers the OAM interrupt
  122. mode_for_interrupt = 2;
  123. StatUpdate();
  124.  
  125. mode_for_interrupt = 1;
  126. StatUpdate();
  127. }
  128.  
  129. StatUpdate();
  130.  
  131. 456 LOOP BACK TO 0
  132.  
  133. Line 153
  134. 0 LY = 153;
  135. ly_for_comparison = -1;
  136. StatUpdate();
  137.  
  138. 4 LY = 0;
  139. ly_for_comparison = 153;
  140. StatUpdate();
  141.  
  142. 8 ly_for_comparison = -1;
  143. StatUpdate();
  144.  
  145. 12 ly_for_comparison = 0;
  146. StatUpdate();
  147.  
  148. 456 current_line = 0;
  149.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement