Advertisement
xerpi

Vita kernel FB set

Feb 9th, 2017
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.04 KB | None | 0 0
  1. #include <psp2kern/display.h>
  2.  
  3. #define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
  4.  
  5. #define SCREEN_PITCH 1024
  6. #define SCREEN_W 960
  7. #define SCREEN_H 544
  8.  
  9. static SceUID fb_uid = -1;
  10.  
  11. int module_start(SceSize argc, const void *args)
  12. {
  13.     unsigned int fb_size = ALIGN(4 * SCREEN_PITCH * SCREEN_H, 256 * 1024);
  14.  
  15.     fb_uid = ksceKernelAllocMemBlock("fb", 0x40404006 , fb_size, NULL);
  16.  
  17.     void *fb_addr = NULL;
  18.     ksceKernelGetMemBlockBase(fb_uid, &fb_addr);
  19.  
  20.     for (int i = 0; i < 544; i++) {
  21.         for (int j = 0; j < 960; j++) {
  22.             ((unsigned int *)fb_addr)[j + i * SCREEN_PITCH] = 0xFF0000FF;
  23.         }
  24.     }
  25.  
  26.     SceDisplayFrameBuf fb;
  27.     fb.size        = sizeof(fb);
  28.     fb.base        = fb_addr;
  29.     fb.pitch       = SCREEN_PITCH;
  30.     fb.pixelformat = SCE_DISPLAY_PIXELFORMAT_A8B8G8R8;
  31.     fb.width       = SCREEN_W;
  32.     fb.height      = SCREEN_H;
  33.  
  34.     ksceDisplaySetFrameBuf(&fb, 1);
  35.  
  36.     return SCE_KERNEL_START_SUCCESS;
  37. }
  38.  
  39. int module_stop(SceSize argc, const void *args)
  40. {
  41.     if (fb_uid) {
  42.         ksceKernelFreeMemBlock(fb_uid);
  43.     }
  44.  
  45.     return SCE_KERNEL_STOP_SUCCESS;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement