Guest User

Untitled

a guest
Oct 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <malloc.h>
  5. #include <ogcsys.h>
  6.  
  7. static void *xfb = NULL;
  8. static GXRModeObj *rmode = NULL;
  9.  
  10.  
  11. void initialise_video()
  12. {
  13. VIDEO_Init();
  14. rmode = VIDEO_GetPreferredMode(NULL);
  15. xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
  16. console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
  17. VIDEO_Configure(rmode);
  18. VIDEO_SetNextFramebuffer(xfb);
  19. VIDEO_SetBlack(FALSE);
  20. VIDEO_Flush();
  21. VIDEO_WaitVSync();
  22. if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
  23. printf("\x1b[2;0H");
  24. }
  25.  
  26. #define isMEM2Buffer(p) (((u32) p & 0x10000000) != 0)
  27.  
  28. int main(int argc, char **argv)
  29. {
  30. initialise_video();
  31.  
  32. while(1)
  33. {
  34. char *ptr = malloc(40);
  35. if(ptr> 0x817fcf00)
  36. {
  37. printf("%p\n", ptr);
  38. if(isMEM2Buffer(ptr))
  39. {
  40. printf("mem2 reached\n");
  41. ptr = malloc(40);
  42. printf("%p\n", ptr);
  43. ptr = malloc(40);
  44. printf("%p\n", ptr);
  45. ptr = malloc(40);
  46. printf("%p\n", ptr);
  47. break;
  48. }
  49. }
  50. }
  51. printf("exiting...\n");
  52. usleep(5000);
  53. return 0;
  54. }
Add Comment
Please, Sign In to add comment