Advertisement
EliteAnax17

Untitled

Feb 16th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. void ProcessDma3Requests(void)
  2. {
  3. // NOTE: the fillerA member of the DMA struct is actually u32 value;
  4. // NOTE: gUnknown_0300001C is just a pointer inside the gDma3Requests structure, not a true symbol; feel free to remove
  5. u16 total_size;
  6.  
  7. if (gDma3ManagerLocked)
  8. return;
  9.  
  10. total_size = 0;
  11.  
  12. while (gDma3Requests[gDma3RequestCursor].size)
  13. {
  14. total_size += gDma3Requests[gDma3RequestCursor].size;
  15.  
  16. if (total_size > 0xA000)
  17. return; // don't do too much at once
  18.  
  19. if (REG_VCOUNT > 224)
  20. return;// we're about to leave vblank, stop
  21.  
  22. switch (gDma3Requests[gDma3RequestCursor].mode)
  23. {
  24. case 1: // regular 32-bit copy
  25. while (gDma3Requests[gDma3RequestCursor].size > 0x1000)
  26. {
  27. DmaCopy32(3, gDma3Requests[gDma3RequestCursor].src, gDma3Requests[gDma3RequestCursor].dest, 0x1000);
  28. gDma3Requests[gDma3RequestCursor].src += 0x1000 >> 2;
  29. gDma3Requests[gDma3RequestCursor].dest += 0x1000 >> 2;
  30. gDma3Requests[gDma3RequestCursor].size -= 0x1000;
  31. }
  32. DmaCopy32(3, gDma3Requests[gDma3RequestCursor].src, gDma3Requests[gDma3RequestCursor].dest, gDma3Requests[gDma3RequestCursor].size);
  33. break;
  34. case 2: // repeat a single 32-bit value across RAM
  35. while (gDma3Requests[gDma3RequestCursor].size > 0x1000)
  36. {
  37. DmaFill32(3, gDma3Requests[gDma3RequestCursor].value, gDma3Requests[gDma3RequestCursor].dest, 0x1000);
  38. gDma3Requests[gDma3RequestCursor].dest += 0x1000 >> 2;
  39. gDma3Requests[gDma3RequestCursor].size -= 0x1000;
  40. }
  41. DmaFill32(3, gDma3Requests[gDma3RequestCursor].value, gDma3Requests[gDma3RequestCursor].dest, gDma3Requests[gDma3RequestCursor].size);
  42. break;
  43. case 3: // regular 16-bit copy
  44. while (gDma3Requests[gDma3RequestCursor].size > 0x1000)
  45. {
  46. DmaCopy16(3, gDma3Requests[gDma3RequestCursor].src, gDma3Requests[gDma3RequestCursor].dest, 0x1000);
  47. gDma3Requests[gDma3RequestCursor].src += 0x1000 >> 1;
  48. gDma3Requests[gDma3RequestCursor].dest += 0x1000 >> 1;
  49. gDma3Requests[gDma3RequestCursor].size -= 0x1000;
  50. }
  51. DmaCopy16(3, gDma3Requests[gDma3RequestCursor].src, gDma3Requests[gDma3RequestCursor].dest, gDma3Requests[gDma3RequestCursor].size);
  52. break;
  53. case 4: // repeat a single 16-bit value across RAM
  54. while (gDma3Requests[gDma3RequestCursor].size > 0x1000)
  55. {
  56. DmaFill16(3, gDma3Requests[gDma3RequestCursor].value, gDma3Requests[gDma3RequestCursor].dest, 0x1000);
  57. gDma3Requests[gDma3RequestCursor].dest += 0x1000 >> 1;
  58. gDma3Requests[gDma3RequestCursor].size -= 0x1000;
  59. }
  60. DmaFill16(3, gDma3Requests[gDma3RequestCursor].value, gDma3Requests[gDma3RequestCursor].dest, gDma3Requests[gDma3RequestCursor].size);
  61. break;
  62. }
  63. gDma3Requests[gDma3RequestCursor].src = NULL;
  64. gDma3Requests[gDma3RequestCursor].dest = NULL;
  65. gDma3Requests[gDma3RequestCursor].size = 0;
  66. gDma3Requests[gDma3RequestCursor].mode = 0;
  67. gDma3Requests[gDma3RequestCursor].value = 0;
  68. gDma3RequestCursor ++;
  69.  
  70. if (gDma3RequestCursor >= 0x80)
  71. gDma3RequestCursor = 0;
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement